Pergunta

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?

Foi útil?

Solução

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);
        }
    }
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top