tags:

views:

19

answers:

1

I have TreeView as below .

Account Payable 
      Address
      Customer 
Account Receivable 
      Address
      Area

If I will select Parent nodes then how I can display in ListView of particular child nodes? Also when I click on root node then how I can display only all parent nodes in ListView?

Thanks .

A: 

I think you're looking for something like this:

Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
    ListView1.Items.Clear()
    If TreeView1.SelectedNode.Nodes.Count > 0 Then
        For Each node As TreeNode In TreeView1.SelectedNode.Nodes
            ListView1.Items.Add(node.Text)
        Next
    Else
        ListView1.Items.Add("Child node is selected")
    End If
End Sub
ho1