Just need to check something with people who know a bit more than I do
Is it possible to "grab" the status (True or False) of a toggle button from a UI builder GUI (on the fly)?
I originally set upt the following in my apply_cb() function
If mytoggle0.GetProperties.GetLogical("Value") Then bCreateTheRecord = True
where: Public Shared bCreateTheRecord As Boolean = False
I expected the code to "grab" the value on the fly but it does't seem to do so
I therefore set up the following in my update_cb() function
If mytoggle0.GetProperties.GetLogical("Value") Then bCreateTheRecord = True Else bCreateTheRecord = False End if
A bit OTT but at least the code is clear. This setup seems to work.
Was my original thinking correct or did I miss something?
Solved! Go to Solution.
It depends on where you want to "grab" it
If you want to capture any change the user makes as soon as it happens, you need to use the update callback. update_cb() is called any time the content of any block is changed on the dialog.
apply_cb() is only called when the Apply button is pressed (or via the ok_cb() when the OK button is pressed).
The template code for the apply_cb() contains an if-elseif tree with a condition for each block on the dialog. You would typically put your code in the conditional set up for that block.
Since you are trying to set a boolean based on the value of a boolean, you could simplify your code below to one line with no conditionals:
bCreateTheRecord = mytoggle0.Value
If this were in the mytoggle0 conditional in the apply_cb(), any time the user changed the toggle, the bCreateTheRecord value would update accordingly
Thanks for that JimB. Looks like my thinking was about right
There is no real/good reason to put the code in the update_cb() function (in the if-elseif block) because I do not anything with the change of status of the toggle button.
Agree that the code presented in my 1st question/email was a bit OTT but I wanted to make sure I go it right. I often do that as a 1st pass because I see the logic quite clearly.
I put the statment: bCreateTheRecord = mytoggle0.Value in the function apply_cb() and the function "grabs" (set !) the status of the boolean variable "on the fly2. Works as I wanted