Hi!
Is it possible to make a radiobutton's ItemIndex change, depending on what another radio button is set to in the same in dialog, without the user having to click a button?
To phrase differently: If i have RadioA with 2 items and RadioB with 2 items, then RadioB changes the selection instantly depending on what is chosen in RadioA, without the user having to confirm his selection with a button push.
Thanks in advance!
Radio button question
Moderators: JRL, Dorian (MJT support)
Re: Radio button question
Not sure how this accomplishes anything but here's an example
Code: Select all
Dialog>Dialog1
object Dialog1: TForm
Left = 557
Top = 96
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'CustomDialog'
ClientHeight = 211
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 = 30
Top = 50
Width = 185
Height = 105
Caption = 'RadioA'
Items.Strings = (
'Selection1'
'Selection2')
TabOrder = 0
Text = 'Selection1'#13#10'Selection2'#13#10
end
object MSRadioGroup2: tMSRadioGroup
Left = 250
Top = 50
Width = 185
Height = 105
Caption = 'RadioB'
Items.Strings = (
'SELECTION1'
'SELECTION2')
TabOrder = 1
Text = 'SELECTION1'#13#10'SELECTION2'#13#10
end
end
EndDialog>Dialog1
AddDialogHandler>Dialog1,MSRadioGroup1,OnClick,Radio1
Show>Dialog1,
SRT>Radio1
GetDialogProperty>Dialog1,MSRadioGroup1,ItemIndex,SelectRes
If>SelectRes=0
SetDialogProperty>Dialog1,MSRadioGroup2,ItemIndex,0
EndIf
If>SelectRes=1
SetDialogProperty>Dialog1,MSRadioGroup2,ItemIndex,1
EndIf
END>Radio1
Re: Radio button question
Thanks! I didn't know you can make OnClick on anything else than buttons
Still learning.

Re: Radio button question
In Dialog Designer, right clicking on an object produces a menu that has "List Event Names" as the fourth item. Clicking that produces a list of the events associated with this particular object. Left click to highlight an item in the list then right click the highlighted item (yes you must do both clicks) a box will appear that says: "Create Handler Call". Pick on that and the appropriate AddDialogHandler> line will be copied to the clipboard. Something like this:
AddDialogHandler>Dialog1,MSRadioGroup1,OnClick,SUBROUTINE_NAME
All you then need to do is replace the text SUBROUTINE_NAME with the desired subroutine name.
AddDialogHandler>Dialog1,MSRadioGroup1,OnClick,SUBROUTINE_NAME
All you then need to do is replace the text SUBROUTINE_NAME with the desired subroutine name.