Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Treeview to open at a specific point vb.net

Status
Not open for further replies.

sjlsysprg

Programmer
Oct 12, 2001
9
US
I have a treeview that is coming from a dataset. When I update or delete the data I need to refresh the treeview and keep the setting of the treeview - if it is expanded.

Thanks in advance.
Suzy


 
I figured it out.
At the TreeView1_AfterSelect
Dim node As System.Windows.Forms.TreeNode
node = TreeView1.SelectedNode
i = node.Index
j = node.Parent.Index

The reload the treeview with the dataset then do the following:

TreeView1.Nodes(i).Expand()
TreeView1.Nodes(i).Nodes(j).Expand()
 
OOPsies : Let me correct one thing:
At the TreeView1_AfterSelect
Dim node As System.Windows.Forms.TreeNode
node = TreeView1.SelectedNode
i = node.Parent.Parent.Index
j = node.Parent.Index

Sorry about the error.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top