I've written two event handlers for the TextBox.Leave
event for a TextBox1
The reason for this is that the first handler is a common one for multiple TextBox.Leave
events which validates the values, and the second one is specific for the above TextBox1
which does some calculation of values.
My query is that can I know which of the two handlers will execute first when TextBox1.Leave
happens?
(I know I can remove the code from the common handler to the specific one for TextBox1
, but still I wish to know if there is a way.)
Thanks
As long as the event handlers are added using the
AddHandler
statement, the event handlers are guaranteed to be called in the same order that they were added. If, on the other hand, you are using theHandles
modifier on the event handler methods, I don't think there is any way to be sure what the order will be.Here's a simple example that demonstrates the order as determined by the order in which
AddHandler
is called:I'd recommend you change to having a single handler, and detect which textbox is being left: