JKwan
05-05-2011, 02:13 PM
I currently have the below code, however, it does not work the way that I wanted. The code will expand all of nodes with a click of a button. The problem is that after the nodes get expanded, I would like to retain my current position. I am not having luck.
below code does not work, can someone give me a pointer as to how I may select back to where my position was before the expand button was clicked?
Private Sub butExpandAll_Click()
Dim xNode As Node
Dim CurrentNode As Node
Set CurrentNode = Me.TreeView1.SelectedItem
For Each xNode In Me.TreeView1.Nodes
xNode.Expanded = True
Next xNode
CurrentNode.EnsureVisible
End Sub
Let me add more comment.... it sort of works, after staring at it for awhile, the once selected node is at the bottom of my tree control, and it is not selected anymore. So, is there a way to move it to the top and selected what was selected?
Thanks
below code does not work, can someone give me a pointer as to how I may select back to where my position was before the expand button was clicked?
Private Sub butExpandAll_Click()
Dim xNode As Node
Dim CurrentNode As Node
Set CurrentNode = Me.TreeView1.SelectedItem
For Each xNode In Me.TreeView1.Nodes
xNode.Expanded = True
Next xNode
CurrentNode.EnsureVisible
End Sub
Let me add more comment.... it sort of works, after staring at it for awhile, the once selected node is at the bottom of my tree control, and it is not selected anymore. So, is there a way to move it to the top and selected what was selected?
Thanks