Question Treeview (Not how to build it)

Rossmc

Member
Joined
Mar 17, 2009
Messages
12
Programming Experience
10+
I have created a parent-child-grandparent treeview with checkboxes.

When I check/uncheck the parent node I want all the child and grandchildren nodes to check/uncheck.

I did this in the treeview_AfterCheck event:

for each nod as treenode in e.node.nodes
nod.checked = e.node.checked
next

At first this seemed to work perfectly but if I rapidly check/uncheck the parent node in the UI the parent and children nodes go out of sync! It possibly has something to do with the fact that the _AfterCheck event is called everytime I programatically check each child node?

What gives? Surely there is a way to handle this correctly?

Thanks in advance...
 
rapid clicking = doubleclicking. TreeView has some known issues regarding checkboxes and doubleclicking, https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=374516
I have tested around 50 different combinations of events to catch this issue, but still haven't found any way to detect this reliably.
VB.NET:
It possibly has something to do with the fact that the _AfterCheck event is called everytime I programatically check each child node?
This is a fact that you should also guard against by checking that e.Action <> TreeViewAction.Unknown, but it won't help the doubleclick problem.
 
Back
Top