By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,603 Members | 1,072 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,603 IT Pros & Developers. It's quick & easy.

expand a treeview at a particular node

P: n/a
Sam
Hi,
Say I have the following Treeview :

N1
|-N11
|-N12
|-N121
|-N122
N2
|-N21
|-N22
|-N221
|-N222
N3

N1, N2 and N3 are collapsed so my tree is enterely collapsed.
Now if N2 is expanded and N222 is selected, when the user clicks on a
button that should delete N222 and the tree should be refreshed and
expanded to N221, which is the previous node (if there was no previous
node, then N22 would be selected - only Nxxx nodes can be deleted).
I know how to get the level of a node :

While Not node Is Nothing
node = node.Parent
level += 1
End While

as well as its index. But N222 and N122 have the same level and index,
so how can I know to which node I should expand my tree ?

Some code would be very welcome !

Thx for your help.

Sam

Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies

P: n/a
Hi,

With node.parent
.EnsureVisible ' make sure the node is visible
.Expand ' Show all of it children
end with

http://msdn.microsoft.com/library/de...xpandtopic.asp

http://msdn.microsoft.com/library/de...sibletopic.asp
Ken
------------------
"Sam" <sa**************@voila.fr> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi,
Say I have the following Treeview :

N1
|-N11
|-N12
|-N121
|-N122
N2
|-N21
|-N22
|-N221
|-N222
N3

N1, N2 and N3 are collapsed so my tree is enterely collapsed.
Now if N2 is expanded and N222 is selected, when the user clicks on a
button that should delete N222 and the tree should be refreshed and
expanded to N221, which is the previous node (if there was no previous
node, then N22 would be selected - only Nxxx nodes can be deleted).
I know how to get the level of a node :

While Not node Is Nothing
node = node.Parent
level += 1
End While

as well as its index. But N222 and N122 have the same level and index,
so how can I know to which node I should expand my tree ?

Some code would be very welcome !

Thx for your help.

Sam
Nov 21 '05 #2

P: n/a
Sam
actually it seems to work by doing :

tvMain.SelectedNode = m_savedNode (m_savedNode being the node that was
previously selected before collapsing the tree) Now since m_savedNode
is meant to be deleted, I have to figure out how to select the previous
node (or that node's parent)

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.