How to deselect Option Button

Started by kruuger · 2010-03-20 00:40 UTC · 6 replies · SMF topic #1219

Hello

I got few Option Buttons. OnInitialize i set value for one of them.
(dcl_Control_SetValue Shortcuts_SHORT_OptionButton1 1)

Next time OnInitialize i want to select next Option Button 2 but dialog box remember also first OptionButton1.

My question is, so every time when i close my dialog i need to change value all of Option Button to 0?

Thanks


For an Option Button 0 = Unchecked; 1 = Checked
(dcl_Control_SetValue Shortcuts_SHORT_OptionButton1 1)



For an OptionList nominate the Selected indexItem (zero based ie 0 = Item1 )
(dcl_Control_SetCurrentSelection Untitled_Form1_OptionList1 < NewValue [as Long] > )
If  the OptionButton1  was set last time you used it and you want OptionButton2 on next time :
Perhaps try something like in the initialize Event :



(cond ((= 1 (dcl_Control_GetValue Shortcuts_SHORT_OptionButton1))
      (dcl_Control_SetValue Shortcuts_SHORT_OptionButton1 0)
      (dcl_Control_SetValue Shortcuts_SHORT_OptionButton2 1)
     )
     ((= 1 (dcl_Control_GetValue Shortcuts_SHORT_OptionButton2))
      (dcl_Control_SetValue Shortcuts_SHORT_OptionButton2 0)
      (dcl_Control_SetValue Shortcuts_SHORT_OptionButton3 1)
     )
     ((= 1 (dcl_Control_GetValue Shortcuts_SHORT_OptionButton3))
      (dcl_Control_SetValue Shortcuts_SHORT_OptionButton3 0)
      (dcl_Control_SetValue Shortcuts_SHORT_OptionButton4 1)
     )
     ((= 1 (dcl_Control_GetValue Shortcuts_SHORT_OptionButton4))
      (dcl_Control_SetValue Shortcuts_SHORT_OptionButton4 0)
      (dcl_Control_SetValue Shortcuts_SHORT_OptionButton4 1)
     )
     ((= 1 (dcl_Control_GetValue Shortcuts_SHORT_OptionButton5))
      (dcl_Control_SetValue Shortcuts_SHORT_OptionButton5 0)
      (dcl_Control_SetValue Shortcuts_SHORT_OptionButton1 1)
     )
     ;; in case none are on
     (T (dcl_Control_SetValue Shortcuts_SHORT_OptionButton1 1))
)

.... when i close my dialog i need to change value all of Option Button to 0


Perhaps try something like this In the OnClose Event :


;;(foreach Control '(Shortcuts_SHORT_OptionButton1 ;<~
(foreach Control (LIST Shortcuts_SHORT_OptionButton1
                  Shortcuts_SHORT_OptionButton2
                  Shortcuts_SHORT_OptionButton3
                  Shortcuts_SHORT_OptionButton4
                  Shortcuts_SHORT_OptionButton5
                 )
 (dcl_Control_SetValue Control 0)
)

Quoted array Changed to LIST
These FOREACH and COND are very nice solution  :)
I like it :)

Thanks Kerry
foreach works but like this:

(foreach Control (LIST Shortcuts_SHORT_OptionButton1  
                   Shortcuts_SHORT_OptionButton2  
                   Shortcuts_SHORT_OptionButton3  
                   Shortcuts_SHORT_OptionButton4  
                   Shortcuts_SHORT_OptionButton5  
                  )  
  (dcl_Control_SetValue Control 0)  
)  
Yes, we'd need to use LIST rather than QUOTE so that the Button ID variables will be evaluated.