I use a treeview of checkboxes.
The root nodes specify the group name.

When the user check the root node I would like to check all its nested notes.

Therefore, I would like to use the CheckChanged event of CheckBox in the treeview.

Is it possible? If so, how?

有帮助吗?

解决方案

You should use AfterCheck event and another help procedure, called recursively. Something like this:

    private void tvwTest_AfterCheck(object sender, TreeViewEventArgs e)
    {
        checkNodes(e.Node);
    }

    private void checkNodes(TreeNode root)
    {
        foreach (TreeNode node in root.Nodes)
        {
            node.Checked = root.Checked;
            checkNodes(node);
        }
    }
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top