Hello,
I would like to implement a menu with a list of StateButtonTools that are programatically added. Based on a condition some of them should be checked, others shouldn't, and their checked state should not change when they are clicked. And all of them should be active, so they can be selected.
I've noticed that in the ToolClick event, the checked state is already changed, so I've tried to restore the previous state, but I get a StackOverflowException, the ToolClick event being raised with every state change.
Can you please guide me to get this behavior.
Thanks,
Emanuel
Hi Emanuel,
If you are getting a StackOverflow, it's because you are changing the CheckState inside the ToolClick event which causes the ToolClick even to be fired again, where you again change the CheckState, etc.
You can stop this sort of recursion by using the EventManager and disabling the ToolClick event while you change the CheckState.
Mike Saltzman"]You can stop this sort of recursion by using the EventManager and disabling the ToolClick event while you change the CheckState.
It seems like StateButtonTool doesn't expose any EventManager property, as I've seen in my searches that UltraComboBox or UltraWinGrid do.
I resolved the issue by using the -= and += operators on the StateButtonTool before changing it's checked value back in the event handler method.
If I have missed to find the EventManager, and it can be used with StateButtonTool, I will appreciate any guiding.
Thank you!
The EventManager would be on the control or component. So in this case it would be on the WinToolBarsManager, not the tool. It's posible that maybe WinToolbarsManager doesn't have an EventManager. I thought it did, but I could be wrong.
In any case, disconnecting the event like you are doing is just as good.