Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Posted

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.

Posted

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'm not lazy i'm just resting before i get tired.
Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...