Frage

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?

War es hilfreich?

Lösung

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);
        }
    }
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top