Help please. how can i get the value in treeview.. Thank You!

Recommended Answers

All 3 Replies

Use 'SelectedNode.Parent.Text'. If you are storing a value in the
node's 'Tag' property, use 'SelectedNode.Parent.Tag.ToString()' to convert
the value to a string -

txtValue.Text = tvMyTreeview.SelectedNode.Parent.Text

You will have something like this if you are using checkboxes in your treeview -

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
2
        For Each tn As TreeNode In Me.TreeView1.CheckedNodes
3

4
            Dim s As String = tn.Value
5
            TextBox1.Text += s & ","
6

7
        Next
8
    End Sub

Thank You!

Only a pleasure. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.