This is a migrated thread and some comments may be shown as answers.

Proplem after changing node text

1 Answer 90 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Osama
Top achievements
Rank 1
Osama asked on 24 Jun 2012, 09:20 AM
Hi..
I have a problem with RadTreeView, when I change the text attribute of node, the value attribute change also to the same value.

please any idea to work around this problem will be Grateful.

Thanks

1 Answer, 1 is accepted

Sort by
1
Stefan
Telerik team
answered on 28 Jun 2012, 07:34 AM
Hello Osamaweb,

Thank you for writing.

When working in unbound mode the Text and the Value properties of the control are linked by default. You can control this behavior via the EditMode property of the TreeViewElement:
radTreeView1.TreeViewElement.EditMode = TreeNodeEditMode.Text;

If you need to store another object in a node, you can use its Tag property.

If you work in bound mode the Value will hold the value of the ValueMemeber field while the Text will hold the DisplayMember field.  Here is an example:
DataTable table = new DataTable();
table.Columns.Add("ID");
table.Columns.Add("Name");
for (int i = 0; i < 10; i++)
{
    table.Rows.Add(i, "Name " + i);
}
radTreeView1.DataSource = table;
radTreeView1.DisplayMember = "Name";
radTreeView1.ValueMember = "ID";

In the code above the Value will hold the "ID" field (1 to 10 in this case) and the Text will hold the "Name" field - "Name 1-10".

I hope that you find this information helpful.
 
Kind regards,
Stefan
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Tags
Treeview
Asked by
Osama
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or