|
-
Nov 22nd, 2002, 08:19 AM
#1
Thread Starter
New Member
using check boxes with the treeview
Hi,
I'm using a tree view control in VB.NET to display the directory structure across all my disk drives. This I have done successfully.
Now, I'm also using check boxes on each node. The idea being that if I check one of the boxes then every check box lower down in the hierarchy will also be checked. This is where I'm stuck.
How can I check every check box on each child node (and subsequent child node) when I check a parent node check box?
I have tried using the BeforeCheck (or AfterCheck) event but the problem is that when I programmatically check the child node, this fires off the very same BeforeCheck event.
Any ideas or suggestions as to how I can do this would be most welcome. Please bear in mind that my competence level with VB.NET is basic.
Thanks,
Karl
-
Nov 22nd, 2002, 10:34 AM
#2
Registered User
This worked for me:
Code:
Private Sub TreeView1_BeforeCheck(ByVal sender As Object, _
ByVal e As System.Windows.Forms.TreeViewCancelEventArgs) Handles TreeView1.BeforeCheck
If Not e.Node.Checked Then
Dim node As TreeNode
For Each node In e.Node.Nodes
node.Checked = True
Next
Else
Dim node As TreeNode
For Each node In e.Node.Nodes
node.Checked = False
Next
End If
End Sub
/Leyan
-
Nov 22nd, 2002, 10:55 AM
#3
Thread Starter
New Member
thanks
Thanks Leyan,
that works perfectly.
Karl
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
|