Hi All,
I need help with adding and deleting nodes(parent nodes) and subnodes(child nodes) in a TreeView. I have a form with a TreeView control that is pre-populated with two parent nodes (named "Finances" and "Personal")both containing two child nodes each when the form is loaded. I would like to add two buttons to this form that would allow me to add new nodes and delete existing nodes from the treeview at run time. Any help with the code for the event handlers for these two buttons is much appreciated.
Below is a snippet of code i have written thus far.
private void frmTreeViewDemo_Load(object sender, EventArgs e)
{
treeView1.Nodes.Clear();
// add a root node to the treeview
treeView1.Nodes.Add("My Wallet");
// create a new treeNode and add sub or child nodes to it
TreeNode node = new TreeNode("Finances");
node.Nodes.Add("Bank Account");
node.Nodes.Add("Credit Card");
// add another node with child nodes
TreeNode node1 = new TreeNode("Personal");
node1.Nodes.Add("ID Card");
node1.Nodes.Add("Passport");
treeView1.Nodes[0].Nodes.Add(node);
treeView1.Nodes[0].Nodes.Add(node1);
treeView1.Nodes[0].Expand();
}