3
Reply

Renaming a Treeview Node using a textbox and button

seraaj isaacs

seraaj isaacs

16 years ago
11.6k

Hi

I'm new to c# and development and I'm sitting with this problem. I have a treeview(TreeViewList), textBox and two buttons. Button1(New), Button2 (Update).

In the update button my code goes like this. If no nodes are selected and textbox is not blank and button new is clicked, Then Add a new child node to parent.

if (selectedNode == null & txtOwners.Text != "" & cmdType == 0)

{

TreeNode tNode = new TreeNode();

tNode.Text = txtOwners.Text.Trim();

rootNode.Nodes.Add(tNode);

In the AfterSelect Event I say that, if SelectedNode != Null, then textbox.Text should display the selectedNode.Text

if (selectedNode != null)

{

txtOwners.Text = selectedNode.Text;

}

My problem is that I also need to add a piece of code in my Update button that says something to the effect, If  TreeViewItem is selected and Textbox.text != null then update the text of the selected node to be = TextBox.Text.

I need urgent help here guys, been searching all over the Internet and in books. found nothing.

Thanks


Answers (3)