Edit

Share via


TreeView Control Overview (Windows Forms)

With the Windows Forms TreeView control, you can display a hierarchy of nodes to users, like the way files and folders are displayed in the left pane of the Windows Explorer feature of the Windows operating system. Each node in the tree view might contain other nodes, called child nodes. You can display parent nodes, or nodes that contain child nodes, as expanded or collapsed. You can also display a tree view with check boxes next to the nodes by setting the tree view's CheckBoxes property to true. You can then programmatically select or clear nodes by setting the node's Checked property to true or false.

Key Properties

The key properties of the TreeView control are Nodes and SelectedNode. The Nodes property contains the list of top-level nodes in the tree view. The SelectedNode property sets the currently selected node. You can display icons next to the nodes. The control uses images from the ImageList named in the tree view's ImageList property. The ImageIndex property sets the default image for nodes in the tree view. For more information about displaying images, see How to: Set Icons for the Windows Forms TreeView Control. If you are using Visual Studio 2005, you have access to a large library of standard images that you can use with the TreeView control.

See also