|
-
Mar 5th, 2006, 12:15 AM
#1
Thread Starter
Fanatic Member
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?
Last edited by ZeBula8; Mar 5th, 2006 at 12:18 AM.
-
Mar 5th, 2006, 03:12 AM
#2
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..
-
Mar 5th, 2006, 04:29 AM
#3
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
Last edited by jcis; Mar 5th, 2006 at 05:28 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|