Radio button question

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Scones
Junior Coder
Posts: 32
Joined: Fri Jul 05, 2019 11:21 am

Radio button question

Post by Scones » Mon Feb 17, 2020 11:23 am

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!

User avatar
JRL
Automation Wizard
Posts: 3392
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Radio button question

Post by JRL » Mon Feb 17, 2020 1:59 pm

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

Scones
Junior Coder
Posts: 32
Joined: Fri Jul 05, 2019 11:21 am

Re: Radio button question

Post by Scones » Tue Feb 18, 2020 8:23 am

Thanks! I didn't know you can make OnClick on anything else than buttons :) Still learning.

User avatar
JRL
Automation Wizard
Posts: 3392
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Radio button question

Post by JRL » Tue Feb 18, 2020 2:11 pm

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.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts