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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find TreeNode by name

Status
Not open for further replies.

seanbo

Programmer
Jun 6, 2003
407
GB
i have a treeview with an unknown amount of treeNodes in it. i have the name of a treenode, how can i use this to get the corresponding treenode?

note - if the treenode i'm looking for should always be there, and it will be a child of treeview.topnode
 
try this...

private TreeNode node(String nodeName, TreeView treeView1){
foreach(TreeNode tempNode in treeView1.TopNode.Nodes){
if(tempNode.Text == nodeName) return tempNode;
}
return null;
}

...it searches every direct child of topnode.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top