Proplem after changing node text

2 posts, 0 answers
  1. Osama
    Osama avatar
    4 posts
    Member since:
    Jun 2012

    Posted 24 Jun 2012 Link to this post

    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

  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 28 Jun 2012 Link to this post

    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 >>
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top