We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

TreeViewAdv InteractiveCheckBoxes

Hi,

The TreeViewAdv InteractiveCheckBoxes property gives me most of the functionality I want (check all child nodes, and set parent nodes to indeterminate), except I would like to be able to keep a parent node checked even if I uncheck all child nodes. Is there a way to do it?

Any help will be greatly appreciated!

Harold


4 Replies

HH Harold Hsu November 17, 2010 01:23 AM UTC

Follow up to my original question...attached is a sample project I did to do what I wanted by having InteractiveCheckBoxes = false and handling the AfterCheck event.

The problem I'm having is that even though I'm programmatically setting the child nodes' CheckState, the child nodes' AfterCheck event is raised with the TreeViewAdvAction set to ByMouse instead of Unknown. Here's the event handler:

private void treeViewAdv1_AfterCheck(object sender, TreeNodeAdvEventArgs e)
{
if (e.Action != TreeViewAdvAction.Unknown)
{
UpdateChildNodes(e.Node);
//UpdateParentNodes(e.Node);
}
}

private void UpdateChildNodes(TreeNodeAdv node)
{
// I can recursively checked all descendant nodes.
foreach (TreeNodeAdv childNode in node.Nodes)
{
childNode.CheckState = node.CheckState;
}
}

If you run the project, and check the root node, you can see all descendant nodes are checked, even though my UpdateChildNodes() does not recursively check all the child nodes. I'd expect TreeViewAdvAction is set to Unknown and the AfterCheck event raised by the child nodes will not execute UpdateChildNodes(). Perhaps I did something wrong?




WindowsFormsApplication2_40f0367a.zip


VS Vallarasu S Syncfusion Team November 22, 2010 04:21 AM UTC

Hi Harold,

Thanks for your interest in Syncfusion products.

In your sample node state processing is handled inside the AfterCheck event, and by design AfterCheck event is processed within the mouse down events, that causes the AfterCheck event to raise with the TreeViewAdvAction as ByMouse.

I have modified your sample to meet your requirement by ignoring the AfterCheck event raised by code.

Please refer the attached sample and let me know if this helps.

Regards
Vallarasu S.




TreeViewSample_fad0aeaa.zip


HH Harold Hsu November 23, 2010 10:04 PM UTC

Thanks!



BA Berkunath A Syncfusion Team August 30, 2012 04:50 AM UTC

Hi Harold,

Thanks for the update.
We are glad to help you out.

Regards,
A.Berkunath


Loader.
Live Chat Icon For mobile
Up arrow icon