0
votes

Is there a way to get tree view to enforce a rule where child nodes require their parent nodes to be checked, without using the node's checked event handler? When a child is checked, but the parent hasn't been, the parent should automatically be checked. When a parent is unchecked, all children should be unchecked.

This will be used in a windows forms application to define access rights for a user. Certain rights depend on another right, hence the requirement to disallow child only selection.

1
Why would you want to avoid the checked event handler? Is this WinForms, etc?LarsTech
@LarsTech Yes, Winforms. I'll edit the post. Wanted to avoid the event handler to eliminate some UI code. Its application is access rights selection. Some access rights can only be granted in combination with another. I just thought tree views might have this built-in, like the one seen for the add windows features dialog, how sub features can't be selected without their parent feature.Kiran Chinnam

1 Answers

0
votes

Without checked event handler you cann't do it.

Develop your own custom Treeview control by inheriting the standard Treeview control. Put code for checked event handler and other validations inside the custom Treeview control. Then use it in your winform.

Advantage is you have a custom Treeview control that can be readily used in many of your WinForm applications for the intended behavior.