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

Reading child nodes on any check or uncheck

4 Answers 293 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Mmm
Top achievements
Rank 1
Mmm asked on 07 Jun 2016, 04:10 PM

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!

4 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 09 Jun 2016, 09:09 AM
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.
0
Mmm
Top achievements
Rank 1
answered on 09 Jun 2016, 03:29 PM

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

0
Mmm
Top achievements
Rank 1
answered on 09 Jun 2016, 05:00 PM

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.

0
Dimitar
Telerik team
answered on 10 Jun 2016, 08:14 AM
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.
Tags
Treeview
Asked by
Mmm
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Mmm
Top achievements
Rank 1
Share this question
or