Visualize, edit, and select hierarchical data as a tree. The WinForms TreeView control can display bound lists of items or custom nodes designed from scratch in Visual Studio.
Visualize and Edit Hierarchical Data
Display your hierarchical list of items, such as indexed entries, directories on a disk, or headings in a document, as a tree structure. TreeView shows parent-child relationships between items in a grouped list.
Provide Selection of Multiple Items
TreeView provides the most efficient way to select multiple, non-adjacent items within a long, hierarchical list. Selection is made possible using checkboxes.
Create Data Bound or Unbound TreeView
The TreeView nodes can be generated automatically from a bound data source. You may also manually create nodes and additional columns in code or at design-time.
TreeView nodes can be implemented as checkboxes, icons, text, or text with images. Selection of multiple, non-adjacent items is possible by displaying checkboxes. Get a variety of different TreeView styles by using a supported WinForms theme.
Programmatically add or remove parent and child nodes. Editing a treeview is unconventional, but the WinForms TreeView makes this possible through special keyboard interaction. The user may edit a node by pressing F2, and finish editing by pressing the Escape key.
Allow users to reorder the nodes by dragging and dropping. TreeView supports drag-and-drop operations within the same treeview as well as among multiple treeviews. Parent and child nodes can also be reordered programmatically.
TreeView supports both keyboard and mouse navigation of nodes. You can expand either a single node or all nodes in the tree. And you can even prevent end-users from collapsing the expanded tree by cancelling the event.
The WinForms TreeView contains a single column by default, but you can add additional columns to display more information. Display additional, underlying data in a bound column or display custom text values in an unbound column.
When working with a data set containing related tables, the WinForms TreeView control can automatically generate KeyField and ParentKeyField properties from relations in the dataset. This helps with hierarchical displays of the tables by setting the datasource and DataMemberPath properties.
The WinForms TreeView provides design-time support in Visual Studio that allows you to manually generate the nodes and columns without writing any code.