|
-
Mar 25th, 2005, 01:32 AM
#1
Thread Starter
Addicted Member
Tree help
i have made a tree with checkboxes, i want to write a code that on its click event the node itself get selected/deselected and if it is a parent node then all of its child should also get selected/deselected. the tree has only two levels. this is the initial code which i write
VB Code:
Dim nd As Node
Set nd = Tree.Nodes.Add()
nd.Key = "AB"
nd.Text = "Address Book"
nd.Tag = "HEADS"
Set nd = Tree.Nodes.Add()
nd.Key = "QR"
nd.Text = "Query List"
nd.Tag = "HEADS"
-
Mar 25th, 2005, 03:45 AM
#2
Addicted Member
Re: Tree help
VB Code:
Private Sub TreeView1_NodeCheck(ByVal Node As MSComctlLib.Node)
On Error GoTo errh:
Dim nodex As Object
If Node.Children = 0 Then
Call MsgBox("This node has no children!", vbInformation + vbOKOnly, "!")
Exit Sub
Else
Set nodex = Node.Child
TreeView1.Nodes(nodex.Index).Checked = True
While (Not IsNull(nodex))
Set nodex = nodex.Next
TreeView1.Nodes(nodex.Index).Checked = True
Wend
End If
errh:
Call MsgBox("All children of " & Node.Text & "(" & Node.Index & ") Checked")
End Sub
Artificial Intelligence At War! - The best game of its genre
Program your own robot and watch it fight in 3d!
Droidarena 3
If I have been useful, please Rate My Post
Support FireFox - 
Microsoft Visual Studio .NET Professional 2003
Microsoft Visual Studio 6, Enterprise Edition
Microsoft Windows XP Professional, Service Pack 2
-
Mar 25th, 2005, 03:45 AM
#3
Lively Member
Re: Tree help
first of all you have to find the no of childrens for a particular parent node.
like... "tree1.children" now u can get the no of children and u should check the condition every click of tree control whether the value is equal to the no of children. using variable..(increment the variable i+1 for every click ok)....r u got it....
-
Mar 25th, 2005, 04:29 AM
#4
Thread Starter
Addicted Member
Re: Tree help
the supplied code is not working, if it is a parent node n i check it, it just displays the msg n its children does not get checked
-
Mar 25th, 2005, 04:55 AM
#5
Thread Starter
Addicted Member
Re: Tree help
hi
i managed to rectify the mistake maself but thnkx neways
check out ma next thread
-
Mar 25th, 2005, 04:59 AM
#6
Addicted Member
Re: Tree help
Well, Yes, that code does work
You just arent adding any child nodes from the look of the first post of this thread.
Artificial Intelligence At War! - The best game of its genre
Program your own robot and watch it fight in 3d!
Droidarena 3
If I have been useful, please Rate My Post
Support FireFox - 
Microsoft Visual Studio .NET Professional 2003
Microsoft Visual Studio 6, Enterprise Edition
Microsoft Windows XP Professional, Service Pack 2
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
|