vendredi 15 avril 2022

vb.net how to trigger a treeview afterCheck event from inside MouseClick event

I have a treeview with parent and child nodes. all of them have check boxes. I did the code of checking/unchecking all the childs when the parent is checked/unchecked.

I have a problem when mouse double click on tree view parent check box, sometimes all the childs get checked some times all of them not checked. thee treeview after check code is working fine , but my problem is with mouse double click , so i need to paste the tree_after check code and trigger it from inside the mouse double click too.

     Private Sub node_AfterCheck(sender As Object, e As TreeViewEventArgs) Handles TreeView1.AfterCheck
            ' The code only executes if the user caused the checked state to change.
            If e.Action <> TreeViewAction.Unknown Then
                If e.Node.Nodes.Count > 0 Then
                    ' Calls the CheckAllChildNodes method, passing in the current 
                    ' Checked value of the TreeNode whose checked state changed. 
                    Me.CheckAllChildNodes(e.Node, e.Node.Checked)
                End If
            End If
        End Sub


 Private Sub TreeView1_MouseClick(sender As Object, e As MouseEventArgs) Handles TreeView1.MouseClick
'how i trigger the node_AfterCheck from here

    End Sub

    Private Sub TreeView1_MouseDoubleClick(sender As Object, e As MouseEventArgs) Handles TreeView1.MouseDoubleClick

'how i trigger the node_AfterCheck from here
    End Sub



Aucun commentaire:

Enregistrer un commentaire