Reading child nodes on any check or uncheck

5 posts, 0 answers
  1. Mmm
    Mmm avatar
    9 posts
    Member since:
    Mar 2011

    Posted 07 Jun Link to this post

    Hi I have following tree structure with checkboxes. I wanted to read the child notes selected or unselected and based on that I want to update a string which store those values

    Tree structure

    Parent1 ((checked))
             --Child11   
             --Child12 (checked)
             --Child13 (checked)

    Parent2(checked)
             --Child21 (checked)
             --Child22
             --Child23

    Parent3 (checked)
             --Child31
             --Child32 (checked)
             --Child33

    Dim ParentsNodes as string

    Dim ChildNodes as string

    I want to loop through entire node with any check or uncheck event and update my ParentNodes string and ChildNodes string so that it says

    ParentsNodes = "Parent1, Parent2, Parent3"

    ChildNodes = "Child12, Child13, Child21, Child32"

     

    How do I loop through my nodes in RadTreeView using VB.NET and in what event should I put this loop so that any check or uncheck updates my strings. Please help

    Thank you!

  2. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 09 Jun Link to this post

    Hi Kanika,

    Thank you for writing.

    You can use the NodeCheckedChanged event. For example:
    Private Sub RadTreeView1_NodeCheckedChanged(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.TreeNodeCheckedEventArgs)
        parentNodes = ""
        childNodes = ""
        For Each item In radTreeView1.Nodes
            If item.Checked Then
                parentNodes += item.Text & ","c
            End If
            For Each child In item.Nodes
                If child.Checked Then
                    childNodes += child.Text & ","c
                End If
            Next child
        Next item
        Console.WriteLine(parentNodes)
        Console.WriteLine(childNodes)
    End Sub

    Please let me know if there is something else I can help you with. 
     
    Regards,
    Dimitar
    Telerik
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Mmm
    Mmm avatar
    9 posts
    Member since:
    Mar 2011

    Posted 09 Jun in reply to Dimitar Link to this post

    Thanks Dimitar ,

     

    It works great, the only problem is that when a node is partially checked I cannot get the parent in my parentNode string. If its fully checked then it captures the parentNode. Is it possible to get the parentnode even if node is partially checked ?

     

    Thanks

  5. Mmm
    Mmm avatar
    9 posts
    Member since:
    Mar 2011

    Posted 09 Jun Link to this post

    One more thing Dimitar,

     

    Is there a event in RADTREEVIEW from telerik which I can put my code as NodeCheckedChanged even triggers on every parent and child check. I want something which triggers only when all checking or unchecking node finishes.

  6. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 09 Jun Link to this post

    Hi Kanika,

    Thank you for writing back.

    I am not sure what you have meant by saying "partially checked" and how exactly you expect this to work for this case. Could you please elaborate. 
     
    In addition, you can use the Validated event to build your strings after the user has finished editing.
    I am looking forward to your reply.

    Regards,
    Dimitar
    Telerik
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Back to Top
UI for WinForms is Visual Studio 2017 Ready