Events sequence question

spebola

Regular
Joined
Mar 9, 2003
Messages
50
Location
Oklahoma City
I have a listview & a treeview on a windows form. The listview has the focus. If a node is clicled in the treeview, the afterselect event for the treeview fires before the leave event for the listview. Is there any way to reverse this event sequence? The treeview was added to the form before the listview. Does this have any effect on the event's sequence?

Any comments would be appreciated.
 
More info on the above question. After further testing the events seem to fire in the following order:

TreeView Click
Treeview BeforeSelect
Treeview AfterSelect
Listview Leave
Treeview Enter

I have duplicated this behavior with a textbox and treeview. The events fire in the above order when the other control has focus and a mouse click is used to select a node in the treeview. If the tab key is used to give the treeview focus, then the events fire in the correct order.
 
sounds wierd... in wierd events situations like that i always try and add some sort of flag to let me know if i want to execute my code or not.
Add a boolean field to your Class and see if you can make that help someway (until you find out the real issue of course)
 
I received the following response from Microsoft on this issue:

I have further researched your first issue regarding the order of the events being fired, and I have confirmed that this is actually by design. The TreeView control gets the click and selection changes events as a result of the mouse click before the focus actually changes to the TreeView control. Therefore you see the order of events as the following:



TreeView1_Click

TreeView1_BeforeSelect

TreeView1_AfterSelect

TextBox1_Leave

TreeView1_Enter



I hope this is helpful. Please let me know if you have any questions about it.
 
Back
Top