The C1TreeNodeCollection class provides the Add method and the Insert method for adding nodes in TreeView. To add a parent node, you can use either of the two methods with the Nodes collection of the C1TreeView class. Next, to add a child node in the parent node, or children nodes in a child node, you can either use the Add method or the Insert method with the Nodes collection of the C1TreeNode class.
The following code snippet demonstrates how to add nodes in the TreeView control using the Add method.
The following image shows the treeview after adding nodes.
The following code snippet demonstrates how to add nodes in the TreeView control using the Insert method.
The final treeview appears, as shown below.
The C1TreeNodeCollection class provides the Remove method and the RemoveAt method for removing nodes from TreeView. You can use either of the two methods with the Nodes collection of C1TreeView to remove parent nodes from TreeView. To remove a child node from a parent node or children nodes from a child node, you can use either of the two methods with the Nodes collection of C1TreeNode.
The Remove method and the RemoveAt method removes a single node at a time. However, to remove all nodes simultaneously from the Nodes collection of TreeView, a parent node, or a child node, you can use the Clear method with the Nodes collection of C1TreeView or C1TreeNode, respectively.
Here is the code snippet demonstrating how to set these methods.
After removing the nodes, the treeview appears like the following.