Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

TT

(*_*)

 

There are 10 types of people in this world;

those that understand binary and those that don't.

Posted

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

TT

(*_*)

 

There are 10 types of people in this world;

those that understand binary and those that don't.

Posted

: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.

TT

(*_*)

 

There are 10 types of people in this world;

those that understand binary and those that don't.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...