How to raise combobox_SelectedIndexChanged(object sender, EventArgs e) programmatically?
Lets say i have method called ClearFields(). I want to call the event before i hit the end of Clearfields() method.
How to raise combobox_SelectedIndexChanged(object sender, EventArgs e) programmatically?
Lets say i have method called ClearFields(). I want to call the event before i hit the end of Clearfields() method.
Just like calling any other method:
Public Sub ClearFields()
...
...
combobox_SelectedIndexChanged(Nothing, Nothing)
End Sub
It's not actually 'raising the event'... When an Event is raised, all it does is call the associated method. combobox_SelectedIndexChanged is just a method attached to an event trigger.
If you need to pass a specific comboBox into the method, replace the first Nothing with the combo box you need to pass.
For your specific case, I think you may be able to call the OnSelectedIndexChanged
method at the end of your own method. Although it seems like clearing the contents of a combo box might raise the event anyway.
You can raise the SelectedIndexChanged
event by selecting (programmatically) a different item in your ListView control.
Just:
combobox_SelectedIndexChanged(null, null);
At the point in your code where you want to invoke the method.