trouble with treeview and parent/child nodes -
Code:
+root
+parent1
-child1
-child2
+parent2
+parent3
-child1
using dotNet v2003
with this example above - how can I determine that parent2 is really a 'parent'?
also, say i click on 'parent3' node, how can I determine that this is a parent node with children?
Re: trouble with treeview and parent/child nodes -
VB Code:
Private Sub TreeView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeView1.Click
Try
Debug.Print(TreeView1.SelectedNode.Parent.Text)
Catch
End Try
End Sub
All I could get..Im sure someone could do something better..
Re: trouble with treeview and parent/child nodes -
You can use GetNodeCount method to know if a node has children, and how many.
GetNodeCount receives a boolean parameter, if True, it returns how many children that node has in all Treeview levels (recursive), if False, it returns how many children it has just in the next level (its direct children).
VB Code:
Dim NodeCount As Integer = TreeView1.SelectedNode.GetNodeCount(True) 'True = Recursive search
If NodeCount = 0 Then
MsgBox("No children!")
Else
MsgBox("This node has " & NodeCount.ToString() & " children")
End If