Question

I want to activate an event handler (i.e. listbox1_selectedindexchanged) in my main subroutine

For example:

Private sub main()

listbox1_selectedindexchanged()

end sub

However, what should I put for parameter "e" and "sender" where e is the system.eventargs and sender is the object??

Was it helpful?

Solution

If you don't use sender and e parameter in the ListBox1_SelectedIndexChanged() method then, you can call like this

ListBox1_SelectedIndexChanged(New Object, New EventArgs)

OTHER TIPS

The cleanest solution would be to extract the code you want to share from the event handler and move it to a separate method. Instead of calling the event handler, you'd call the method from both the event handler and your sub main.

However, if you want to call the event handler directly, you can specify the control as sender (in your case listbox1) and EventArgs.Empty (thanks @AndrewMorton) as parameter "e":

listbox1_selectedindexchanged(listbox1, EventArgs.Empty)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top