String said:
Dim cb() As New ComboBox()
Protected Overrides Sub OnCreateControl()
AddHandler cb.SelectedIndexChanged, AddressOf ComboBox_TextChanged
End Sub
Keep in mind that an array is a Data Type, unlike VB 6 it is an object in
and of itself (with some neat tricks when you declare an Array of a specific
type). It makes no sense to put an event handler on it (at least not in
this case). What you are saying is this: "When the array's SelectedIndex
Property changes, fire this event", when in reality, the array has no such
event, the event is a member of the array contents, not the array itself. So
what you want to do is loop through each item in the list/array and process
them seperatly. I don't fully understand why the IDE even let you do this
in the first place - it should throw a syntax error.
Try this code:
Dim cb( ) As New ComboBox()
Protected Overrides Sub OnCreateControl( )
Dim cbThis as ComboBox
For Each cbThis in cb
AddHandler cb.SelectedIndexChanged, AddressOf ComboBox_TextChanged
Next
End Sub
HTH,
Jeremy