Collapse sibling nodes in 2.0 Treeview

C

christoffer.lantz

Howdy folks. Would anyone care to suggest a way to have sibling nodes
(at the same level) collapse when a node is expanded in an asp.net 2.0
treeview control? What I mean is that I want only one subtree to be
open at a time. Can the treeview control do this by itself or is some
fiddeling required?

Regards,
Lantz
 
G

Guest

Hello Christopher,

My experience with the Treeview would say that you need to manage the state
of the nodes yourself and that Treeview.FindNode() is your friend:

// Function to collapse all the nodes of a treeview control but the given
parameter

protected void ExpandNode(string expandThisNode)
{
foreach (TreeNode tn in myTreevie.Nodes)
{
tn.Collapse();
}
TreeNode tnExpandThisNode = tvPhoto.FindNode((string)expandThisNode);
tnExpandThisNode.Expand();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top