TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
John Q
NA
12
44.3k
Searching for a Treeview and collapse it
Jan 22 2014 9:08 AM
I've a treeview and I want to search for a particular node everywhere in the treeview and when it finds it, it need to collapse it. I've the following code but it doesn't seem to do the collapsing, if anyone has any idea please post some tips. Thanks in advance
private void FindByText()
{
TreeNodeCollection nodes = treeView1.Nodes;
foreach (TreeNode n in nodes)
{
FindRecursive(n);
}
}
private void FindRecursive(TreeNode treeNode)
{
string collapseStr = "";
foreach (TreeNode tn in treeNode.Nodes)
{
collapseStr = tn.ToString();
if (collapseStr.StartsWith("sub1"))
tn.Collapse();
FindRecursive(tn);
}
}
It needs to collapsing all the node = "sub1" below.
Node1
sub1
sub2
sub3
Node2
sub1
sub2
sub3
Reply
Answers (
2
)
C# code for date wise filtering
guid