code show as below
private void tvMen_AfterSelect(object sender, TreeViewEventArgs e) { // Judge the node level, if it is not the root node, when selected, the corresponding value will be displayed in the text box if ( this .tvMen.SelectedNode.Level != 0 ) { // Display the text of the node in the text box this .textBox123.Text = e.Node.Text; } { } } // Add root node private void btgjd_Click( object sender, EventArgs e) { if (this.textBox123.Text != string.Empty) { // Create a node object TreeNode rootNode = new TreeNode( this .textBox123.Text); // Add node as TreeViwe root node this .tvMen.Nodes.Add(rootNode); } { } } // Add a child node to a node in the TreeView control private void btzjd_Click( object sender, EventArgs e) { // Check that the text box is not empty and select a node if ( this .textBox123.Text != string .Empty && this .tvMen.SelectedNode != null ) { // Create a child node object TreeNode child = new TreeNode( this .textBox123.Text); // Add the node as the selected child node this .tvMen.SelectedNode.Nodes.Add(child); } else { MessageBox.Show( " Please select a root node " ); } } }