XOJO 2019r3.2 / Windows Desktop
My problem ,
I have a set of CheckBoxes that can individually be changed by the user.
Everytime a CheckBox changes a ListBox will be updated.
That works fine.
I have 3 buttons -> ‘Select All’, ‘Select None’ and ‘Invert Selection’ for changing the same set of CheckBoxes.
What happens : when I select ‘All’ ‘None’ or ‘Invert’ the CheckBox Set action will be launched for all the changed CheckBoxes. The ListBox will be updated multiple times, and that should be only once after clicking 'All, ‘None’ or ‘Invert’.
I’m looking for a solution for this problem.
It is perhaps easy, but I cannot find a correct solution.
Do not perform your ListBox actions in the CheckBox Events.
Quick & Dirty:
- Create a single Method which performs the actions you did before in those CheckBox Events.
- Start this Method using Xojo.CoreTimer.CallLater.
- Do a CancelCall before those CallLater calls.
CheckBox Event Example:
Xojo.Core.Timer.CallLater(50, AddressOf DoListBoxStuff)
This way, the ListBox actions would be performed with a delay when a CheckBox Value changes. The CancelCall before the CallLater would stop the execution and so only the last Call should be performed.
Ok I quickly tested the second solution with the ‘If Me.Enabled Then’ and that seems to work for me.
Further tests will be done to be sure if everything works fine that way.
Thank you very much Sascha S.
Or you could Subclass the CheckBox and implement a silent toggle so the Action event isn’t triggered.
The link you provided is not working for me.
Ok I could download the project code.
That’s a very nice solution too for my problem. It works very well.