Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This example adds one node to the selected node of an existing TreeView control.
Example
try
{
TreeNode node = treeView1.SelectedNode;
node.Nodes.Add("New node below selected node");
}
catch (Exception)
{
// Handle the exception.
}
Compiling the Code
This example requires:
- A TreeView control named treeView1.
Robust Programming
The following conditions may cause an exception:
- The TreeView control has no nodes or none of the nodes is selected.
See Also
Concepts
Designing a User Interface in Visual C#