Вопрос

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