tri state treeview check / uncheck / Indeterminate parent only

796 Views Asked by At

I am using a tri state treeview, I want to be able to check check a parent only without checking all or part of its children or giving it Indeterminate state. I used this function but it is not working properly

private void treeSysFunctions_AfterCheck(object sender, TreeViewEventArgs e)
    {          
        if (!e.Node.Checked)
        {
            TreeNode parent = e.Node.Parent;
            if (parent != null)
            {
                bool hasCheckedChild = HasCheckedChild(parent);

                if (!hasCheckedChild)
                    treeSysFunctions.SetChecked(parent, Elegant.Ui.Extensions.TriStateTreeView.CheckState.Indeterminate);
            }
        }
    }
0

There are 0 best solutions below