Listbox Event Handler Problem
Hi,
I am creating a web parts control containing a listbox, a button and a context menu using visual basic.net. I have created both controls and would like to add a selectionIndexChanged event handler for the listbox but the intellisense list did not display the listbox control.
Here is a code snippet:
Protected Overrides Sub CreateChildControls()
listbox1 = new listbox //adding a listbox control
listbox1.ID = "List1"
listitem1.Text = "Testing"
listbox1.Items.Add(listitem1)
Me.Controls.Add(listbox1)
//intellisense didnt display the listbox for event handling! [?]
button1 = new button //adding a button control
button1.ID = "Button1"
button1.Text = "Test"
Me.Controls.Add(button1)
AddHandler button1.Click, AddressOf button1_Click //intellisense did include the button control for event handling
End Sub
How do I allow event handling for the listbox? It seems that vb was unable to recognise the listbox for AddHandler
Re: Listbox Event Handler Problem
Did you create the listbox in code¿
If so, the only thing I can think of is to maybe declare your listbox WithEvents
Code:
Public WithEvents List1 As ListBox
Or am I understanding you wrong¿
Re: Listbox Event Handler Problem
Thank you for the reply
I've tried it and now there is an event handler for the listbox.
Re: Listbox Event Handler Problem
Quote:
Originally Posted by ZhiYi
Thank you for the reply
I've tried it and now there is an event handler for the listbox.
Ah, That's good news!
Good Work!