TreeView

Displays the items in a tree format. The items of TreeView control, are called as “Nodes”. The nodes can be expanded or collapsed at run time.
TreeView
API: System.Windows.Forms.TreeView
Naming Convension: treexxxxxx

Property Description
Nodes Contains the list of nodes.
ShowRootLines Enables / disables the root lines
ShowPlusMinus Enables / disables the plus and minus symbols.
Name, BackColor, ForeColor, Enabled, Visible, Size, Location, ContextMenuStrip, BorderStyle

Events of TreeView
Event Description
AfterSelect, Click, DoubleClick, MouseMove, MouseEnter, MouseLeave, KeyPress, Enter, Leave

Run Time Properties of TreeView
Property Description
SelectedNode Represents the currently selected node in the tree view
SelectedNode.Text Gets the text of the currently selected node.
SelectedNode.FullPath Gets the full path of the currently selected node.
Nodes.Count Gets the count of all the nodes in the tree view.

Demo on TreeView

TreeView
private void treeMyTree_AfterSelect(object sender, TreeViewEventArgs e)
{
lblSelectedNode.Text = treeMyTree.SelectedNode.Text;
lblSelectedNodePath.Text = treeMyTree.SelectedNode.FullPath;
}

private void btnExpandAll_Click(object sender, EventArgs e)
{
treeMyTree.ExpandAll();
}

private void btnCollapseAll_Click(object sender, EventArgs e)
{
treeMyTree.CollapseAll();
}