Help Me! About Treeview Control In VB.NET

  • 11 years ago

    How can I Collect all the Checked Child Nodes Name From a TreeView Control Using VB.NET. Thanks In Advanced.

  • 11 years ago

    Dim i As Integer

    For i=0 to TreeView1.CheckedNodes.Count-1

     Dim tn As New TreeNode()
      tn = TreeView1.CheckedNodes.Item(0)
      Dim intvalue As Integer = tn.Value

    Next i

    By Above loop u can get the value of checked node in tn.value and collect in string or anything you want..

    Please reply if you get satisfied... Cheers...!!!!

  • 11 years ago

    Many many Thanks for ur code. But Its not working in VB.NET. Is it VB6 Code ?


    Treeview1.CheckedNodes Not working.

    There are no Property named CheckNodes with TreeView Control. Thanks.

  • 11 years ago

    No popel its VB.Net Code only ....u might be missing something... Treview is having property Checkednodes in .Net

  • 11 years ago

    I have Just Placed a Treeview Control ( Named Treeview1) and a Command Button on my Form. In Command Button Click Event I have paste your code.

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i As Integer

        For i = 0 To TreeView1.CheckedNodes.Count - 1
            Dim tn As New TreeNode()
            tn = TreeView1.CheckedNodes.Item(0)
            Dim intvalue As Integer = tn.Value
        Next i
    End Sub

    Error is : Error 1 'CheckedNodes' is not a member of 'System.Windows.Forms.TreeView'. E:\SSC Practise\TestSsc\TestSsc\Form1.vb 99 22 TestSsc

    What should I Do?


  • 11 years ago

    well by the error and code it seems the u are working on windows application ...and the code i have given is for Web Application...

    Anyways i didnt worked in windows but i think u might go through all the properties u might get someway to get the required thing...

    just check weather you have selected node property by this you can check weather selected node is checked or not....

    TreeView1.SelectedNode.Checked = True

  • 11 years ago

    Thanks For all. Can any one help me Plz.

  • 11 years ago

    Well........... at last the problem solved.

    here is the code........

    .......................... ........................

    Private Function GetCheckedChildNodes(ByVal nodes As TreeNodeCollection) As TreeNode() Dim checkedNodes As New List(Of TreeNode)

    For Each node As TreeNode In nodes
        If node.Checked AndAlso node.Level > 0 Then
        End If
    Return checkedNodes.ToArray()

    End Function

    ......................... .........................

    Private Sub Button1_Click() Handles Button1.Click For Each node In Me.GetCheckedChildNodes(Me.TreeView1.Nodes) Console.WriteLine(node.FullPath) Next End Sub

    Thanks to all.


Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“A computer lets you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila” - Mitch Ratcliffe