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

Renaming Nodes

1 Answer 124 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Omid
Top achievements
Rank 1
Omid asked on 02 Sep 2013, 09:43 PM
hi telerik

i save nodes  name in sql database ,how can i get new name  after renaming a node  .?
i test this codes  :

Private Sub TreeDevices_TextChanged(sender As Object, e As EventArgs) Handles TreeDevices.ValueChanged
     
   dim Com as sqlcommand=" update Table1 set Field2='" &  TreeDevices.SelectedNode.Name & "' where field1 = " & TreeDevices.SelectedNode.Tag

            con.Open()
            com.ExecuteNonQuery()
            con.Close()
     
    End Sub

 after renaming a node event  "TreeDevices.ValueChanged" occur   but  "TreeDevices.SelectedNode.Name"  still return old name.
what can i do?

thank you
omid




1 Answer, 1 is accepted

Sort by
0
George
Telerik team
answered on 05 Sep 2013, 02:12 PM
Hi Omid,

Thank you for writing.

In this case you can save the old node name and send another query to the database, read the data and find the old node by name or text, and change it after that. A sample code looks like this:
Dim cmd As New SqlCommand("Select Field2 from Table1 where Field2 = " + previousNodeName, Me.conn)
Dim reader As SqlDataReader = cmd.ExecuteReader()
reader.Read()
Dim newName As String = DirectCast(reader(0), String)
 
Dim foundNode As RadTreeNode = Me.FindNodes(previousNodeName)(0)
foundNode.Text = newName

Additionally we have some great articles about databinding a RadTreeView. You can find them in our help section - http://www.telerik.com/help/winforms/treeview-data-binding-data-binding-basics.html.

I hope this helps.

Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Treeview
Asked by
Omid
Top achievements
Rank 1
Answers by
George
Telerik team
Share this question
or