Event order

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm having a problem with the order in which events are raised..

I have a form that contains a treeview and a textbox. When I click on the treeview control from the textbox, the textbox's Validate event isn't fired until after the treeview's AfterSelect is fired. This seems like a bug to me.

Does anyone know a way to control the order of events? I want the TextBox's Validate event to fire first, then only if it passes should the next event (Treeview's AfterSelect) fire

Thanks.
 
I don't think that's possible, but i'd also be interested in this...

I've developed quite a lot of UI controls and had found the validate event
to be, let's just say, quite useless...
Can you try manually invoking the AfterSelect event from the validate event
of a textbox?

Chris G. said:
I'm having a problem with the order in which events are raised...

I have a form that contains a treeview and a textbox. When I click on the
treeview control from the textbox, the textbox's Validate event isn't fired
until after the treeview's AfterSelect is fired. This seems like a bug to
me.
Does anyone know a way to control the order of events? I want the
TextBox's Validate event to fire first, then only if it passes should the
next event (Treeview's AfterSelect) fire.
 
I think that the reason for this is that the validate event of the TextBox
is fired by the TreeView. If the TreeView control's CausesValidation
property is set to False, the event will not fire at all in the TextBox. As
I understood it, the reason for this is that you should be able to build a
user interface with "coupled controls".An example could be a textbox in
which you must enter a number, and a trackbar that will set a value in the
text box. If you enter the textbox, erase the value and then try to use the
TrackBar to set a value, the Validation event of the textbox would prevent
the user from doing so. Solution: set the CausesValidation property of the
TrackBar to False and the validate event of the textbox won't fire. If you
move from the text box to any other control it will.

At least this is how I understood it.

brg

/fredrik
 
If you're feeling adventurous, you could try overriding the WndProc on your
form and catching both of the events, then seeing if there's some way to
change around which happens when. But that sounds like an invitation for
flakiness if there ever was one. It'd be extremely tricky. But it's the only
way I know that it would be possible, if it is indeed possible.

Chris

Chris G. said:
I'm having a problem with the order in which events are raised...

I have a form that contains a treeview and a textbox. When I click on the
treeview control from the textbox, the textbox's Validate event isn't fired
until after the treeview's AfterSelect is fired. This seems like a bug to
me.
Does anyone know a way to control the order of events? I want the
TextBox's Validate event to fire first, then only if it passes should the
next event (Treeview's AfterSelect) fire.
 
Back
Top