We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Checked Nodes in Treeview

Thread ID:

Created:

Updated:

Platform:

Replies:

92235 Dec 30,2009 01:47 AM UTC Dec 30,2009 12:36 PM UTC ASP.NET Web Forms (Classic) 1
loading
Tags: Tools
Ronald Rasmussen
Asked On December 30, 2009 01:47 AM UTC

If I use the folowing code to walk through the checked nodes in a treeview will I ever get a child node BEFORE I get the parent node?

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)

For Each tv As TreeViewNode In TreeView1.SelectedNodes

Text1.Text += tv.Text

Next tv

End Sub

Venkatesh S [Syncfusion]
Replied On December 30, 2009 12:36 PM UTC

Hi Ron,

Thank you for your interest in Syncfusion products.

The child nodes can be retrieved before their parent node.

Following code snippet can be used to acheive your requirement

[C#]

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim allCheckedNodes As New List(Of TreeViewNode)()
childparent(TreeView1.Items, allCheckedNodes)
For Each tv As TreeViewNode In allCheckedNodes
Text1.Text += tv.Text
Next tv
End Sub

Protected Sub childparent(ByVal listItems As IList, ByVal list As List(Of TreeViewNode))
For Each tv As TreeViewNode In listItems
If tv.HasSubNodes Then
childparent(tv.Items, list)
End If
If tv.Checked AndAlso tv.ShowCheckBox Then
list.Add(tv)
End If
Next tv
End Sub


Please let us know if it helps you.

Regards
Venkatesh

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;