Home
Manage Your Code
Snippet: Select a node in a TreeView Programatically (C#)
Title: Select a node in a TreeView Programatically Language: C#
Description: Using C# and .NET Framework 2.0, programatically select a specific node in the TreeView control. Views: 232
Author: Dirk Strauss Date Added: 1/23/2008
Copy Code  
1//The TreeView control is called treeView1

2//We want to programatically select the first node like this:

3this.treeView1.SelectedNode = this.treeView1.Nodes[0];
Notes
The TreeView control is called treeView1 We want to programatically select the first node To select a different node, replace the number between the [ ] brackets with the required index.