C # TreeView Continuous Click does not trigger Aftercheck event

Source: Internet
Author: User

Create a class TreeView2

Namespace System.Windows.Forms
{public
    class Treeview2:treeview
    {
        protected override void WndProc ( Ref message M)
        {
            if (m.msg!= 0x203)
            {
                base. WndProc (ref m);}}}

The foreground then places a TreeView control. Name: TreeView1


Background code:

private void Form3_load (object sender, EventArgs e) {//test data TreeNode t = new TreeNode ();

            T.text = "All Permissions";
            TreeNode T1 = new TreeNode (); T1.
            Text = "Member consumption";

            T.nodes.add (t1);
                for (int i = 0; i < i++) {TreeNode t2 = new TreeNode (); T2.
                Text = "Test" + i; T1.
            Nodes.Add (T2);
            } this.treeView1.CheckBoxes = true;

        THIS.TREEVIEW1.NODES.ADD (t); } private void Checkallchildnodes (TreeNode TreeNode, bool nodechecked) {foreach (TreeNode no De in Treenode.nodes) {node.
                Checked = nodechecked; if (node. Nodes.count > 0) {this.
                Checkallchildnodes (node, nodechecked);
        }} private void Treeview1_aftercheck (object sender, TreeViewEventArgs e){if (e.action!= treeviewaction.unknown) {if (E.node.nodes.count > 0) {this.
                Checkallchildnodes (E.node, e.node.checked); }
            }
        }

Finally, replace the TreeView in the Form3.Designer.cs file with our TreeView2



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.