C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Search Node in a TreeView


Posted Date: 23 May 2007    Resource Type: Code Snippets    Category: Application windows, menus & toolbars

Posted By: Rohit       Member Level: Gold
Rating:     Points: 10



This Code Snippet will traverse the treeview for specific value and select the node that contains the value.

The variable used are:

TreeView trvSourceCode;
bool m_bNodeFound ;



private void FindNodeInHierarchy(TreeNodeCollection nodes, string strSearchValue)
{
for (int iCount = 0; iCount < nodes.Count; iCount++)
{
if (nodes[iCount].Text.ToUpper().Contains(strSearchValue.ToUpper()))
{
trvSourceCode.SelectedNode = nodes[iCount];
trvSourceCode.Select();
m_bNodeFound = true;
return;
}
else
{
m_bNodeFound = false;
}
//expand the nodes
nodes[iCount].Expand();
//Recursively search the text in the child nodes
FindNodeInHierarchy(nodes[iCount].Nodes, strSearchValue);
if (m_bNodeFound)
{
return;
}
//collapses the nodes
nodes[iCount].Collapse();
//return;
}
}






Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Call a method in Active MDI Child Form from the MDI Parent
Previous Resource: How to create a context menu and attach it to a control?
Return to Discussion Resource Index
Post New Resource
Category: Application windows, menus & toolbars


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

internet fax

Contact Us    Privacy Policy    Terms Of Use