سؤال

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