TechnoTone Posted September 24, 2003 Posted September 24, 2003 I want to use the AfterCheck event on a TreeView to ensure all child nodes to the node that was checked/unchecked are the same. Unfortunately, the AfterCheck event doesn't tell you which node was checked/unchecked and the TreeView's selected node doesn't change either. Any suggestions? Quote TT (*_*) There are 10 types of people in this world; those that understand binary and those that don't.
TechnoTone Posted September 24, 2003 Author Posted September 24, 2003 I've found 1 solution but it isn't ideal. It involves moving the selected node as the mouse moves over the control so that the selected node will alway match the clicked node. If there is another way I'd be most interested in hearing of it. Private Sub TreeView1_AfterCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterCheck Static bIgnore As Boolean If bIgnore Then Exit Sub bIgnore = True CheckTree(TreeView1.SelectedNode) bIgnore = False End Sub Private Sub TreeView1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TreeView1.MouseMove TreeView1.SelectedNode = TreeView1.GetNodeAt(e.X, e.Y) End Sub Private Sub CheckTree(ByVal RootTreeNode As TreeNode) With RootTreeNode Dim subNode As TreeNode For Each subNode In .Nodes subNode.Checked = .Checked CheckTree(subNode) Next End With End Sub Quote TT (*_*) There are 10 types of people in this world; those that understand binary and those that don't.
*Gurus* divil Posted September 24, 2003 *Gurus* Posted September 24, 2003 The AfterCheck event _does_ tell you which node was checked :) Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
TechnoTone Posted September 24, 2003 Author Posted September 24, 2003 :eek: Thanks Divil. I could've sworn I checked the parameters and didn't find it. Oops!! I'll get my coat. I could still do with some advice on my other issue though. Quote TT (*_*) There are 10 types of people in this world; those that understand binary and those that don't.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.