that is a question I have been asking myself for a while.
Giving a certain flow of events, can I when handling one of them, stop the next ones to be raised?
For example, when collapsing a node which child was selected in a treeview (winform), the events are raised like that:
- BeforeCollapse
- BeforeSelect
- AfterSelect
- AfterCollapse
I could stop them by using a class member, but I was wondering whether there was a built-in function or just another way (a more elegant way) to achieve this, by acting directly on the events queue.
Any idea?
Not easily, no. The order of the events firing is controlled by the TreeView control class, and there is no built-in way to prevent events from firing. But you have a couple of options:
then add a
boolproperty to prevent the events from processing.Then you can override
BeforeCollapse, etc. to check the boolbefore calling
base.BeforeCollapse.boolflag, and check the flag in each of the events.