Renaming Nodes

2 posts, 0 answers
  1. Omid
    Omid avatar
    1 posts
    Member since:
    Sep 2013

    Posted 02 Sep 2013 Link to this post

    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




  2. George
    Admin
    George avatar
    500 posts

    Posted 05 Sep 2013 Link to this post

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