Listbox event at runtime

can I find out at runtime if a listbox has a certain event handler specified ?

Put code in that Event ?

Try to AddHandler the event and see if it works

[code]Sub Action()
#Pragma BreakOnExceptions False


AddHandler lb.Change, AddressOf hackChange //if already implemented goes to the catch

RemoveHandler lb.Change, AddressOf hackChange

MsgBox "lb.Change not implemented"


MsgBox "lb.Change is implemented"


End Sub

Private Sub hackChange(sender As Listbox)
End Sub[/code]

Note, a totally empty event handler is not implemented.

sorry, but can I also use introspection to find out if a listbox event exists ?

Sure. Get the methods and search for your event names prefixed by “Event_”

[code]Sub Action()

dim ti As Introspection.TypeInfo = Introspection.GetType(myListBoxInstance)

dim targetEvent As String = “Event_” + “MouseDown”

dim ma() As Introspection.MethodInfo
for i As integer = 0 to ma.Ubound

if ma(i).Name = targetEvent then
  MsgBox "found " + targetEvent


End Sub[/code]

That will tell you events added to the class of myListBoxInstance. It’s the same with a Window to get it’s events. But for events added to a control on a Window get the TypeInfo of the Window and search for “ControlName” + “_” + “EventName”.

Note this won’t tell you if the event is empty or an AddHandler was used.

thanks Will, that helps a lot