|
-
February 20th, 2006, 04:44 AM
#1
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
-
February 20th, 2006, 08:00 AM
#2
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¿
-
February 20th, 2006, 10:00 PM
#3
Re: Listbox Event Handler Problem
Thank you for the reply
I've tried it and now there is an event handler for the listbox.
-
February 21st, 2006, 12:50 AM
#4
Re: Listbox Event Handler Problem
 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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|