954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

C# TreeView Node Expand / Collapse Events

Can someone please tell me what is the event that is triggered when a user clicks on the + sign in C# TreeView?

To elaborate more, here is my problem.

I have a tree view that is populated at the time of Form_Load. Then the user can expand/collapse/select etc with it. However, from time to time, the tree view might get data from a service, and once it does and the nodes are changed it will automatically update with new data. This update function is such that it populates the whole tree view from the beginning - simply it calls the methods that is called at Form_Load.

My requirement is, let's say I had a certain portion of the Tree expanded by clicking on the little + icon. (Note that I haven't SELECTED any nodes, just clicked on the little icon only. Thus I cannot use the SelectedNode property.) So imagine while I have a certain part of the Tree expanded, some new data comes in and the TreeView is drawn again. Now, I want the TreeView to display the previously selected portion again after it finished it's updating.

How can I do it?

In the case the user had actually selected a node, I can remember it before updating and then user Node.EnsureVisible() to go back to the selection. Wonder how I can achieve it when the user has only clicked on the little + icon.

sachintha81
Junior Poster in Training
96 posts since Apr 2008
Reputation Points: 35
Solved Threads: 1
 

Wouldn't that be the BeforeExpand/BeforeColapse events (along with the AfterExpand/AfterColapse).

Momerath
Nearly a Senior Poster
3,386 posts since Aug 2010
Reputation Points: 1,232
Solved Threads: 558
 

check this treeview sample , it will help u

http://csharp.net-informations.com/gui/cs-treeview.htm

jerry.

jerry32uk
Newbie Poster
14 posts since Apr 2008
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: