I am trying to make two radio button objects dependent on each other, but I can't figure out how to reset or set a radio button from the code. I have tried to set the SelectedItem to null, an index value, and the actual value, but no luck.
What I need is two radio button objects that are dependent on each other as follows. The first radio button object has options A and B. The other radio button object has options 1, 2, and 3. Valid combinations are A1, B2, and B3. So if the user tries to select A2, A3, or B1, I would like to reset the radion buttons to null.
I found an old post about using ResetDialogAction, but the documentation says that this command has been Depreciated. So I guess I am looking for suggestions.
Thanks,
Andrew T
Designing Radio Buttons
Moderators: Dorian (MJT support), JRL
- Grovkillen
- Automation Wizard
- Posts: 1131
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
Re: Designing Radio Buttons
They need to be in the same group.
Re: Designing Radio Buttons
Not sure I have your logic perfect but here is an example
Code: Select all
Dialog>Dialog1
object Dialog1: TForm
Left = 613
Top = 189
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'CustomDialog'
ClientHeight = 185
ClientWidth = 476
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 13
object MSRadioGroup1: tMSRadioGroup
Left = 31
Top = 14
Width = 185
Height = 105
Caption = 'MSRadioGroup1'
Items.Strings = (
'1'
'2')
TabOrder = 8
Text = '1'#13#10'2'#13#10
Text = 'A'#13#10'B'
end
object MSRadioGroup2: tMSRadioGroup
Left = 252
Top = 14
Width = 185
Height = 105
Caption = 'MSRadioGroup2'
Items.Strings = (
'A'
'B'
'C')
TabOrder = 9
Text = '1'#13#10'2'#13#10'3'
end
end
EndDialog>Dialog1
AddDialogHandler>Dialog1,MSRadioGroup1,OnClick,CheckGroup1
AddDialogHandler>Dialog1,MSRadioGroup2,OnClick,CheckGroup2
Show>Dialog1,
SRT>CheckGroup1
GetDialogProperty>Dialog1,MSRadioGroup1,ItemIndex,Index1Res
GetDialogProperty>Dialog1,MSRadioGroup2,ItemIndex,Index2Res
If>{("%Index1Res% %Index2Res%"="0 0")or("%Index1Res% %Index2Res%"="1 1")or("%Index1Res% %Index2Res%"="1 2")or(%Index1Res%=-1)or(%Index2Res%=-1)}
Else
SetDialogProperty>Dialog1,MSRadioGroup1,ItemIndex,-1
SetDialogProperty>Dialog1,MSRadioGroup2,ItemIndex,-1
EndIf
END>CheckGroup1
SRT>CheckGroup2
GetDialogProperty>Dialog1,MSRadioGroup1,ItemIndex,Index1Res
GetDialogProperty>Dialog1,MSRadioGroup2,ItemIndex,Index2Res
If>{("%Index1Res% %Index2Res%"="0 0")or("%Index1Res% %Index2Res%"="1 1")or("%Index1Res% %Index2Res%"="1 2")or("%Index1Res% %Index2Res%"="1 2")or(%Index1Res%=-1)or(%Index2Res%=-1)}
Else
SetDialogProperty>Dialog1,MSRadioGroup1,ItemIndex,-1
SetDialogProperty>Dialog1,MSRadioGroup2,ItemIndex,-1
EndIf
END>CheckGroup2
Re: Designing Radio Buttons
Thanks JRL!
The logic is basically what I had figured out, but it was the setting ItemIndex to -1 instead of the SelectedItem property that I needed.
Andrew T
The logic is basically what I had figured out, but it was the setting ItemIndex to -1 instead of the SelectedItem property that I needed.
Andrew T