Table of Contents

Radio Group Guide

TTMSFNCRadioGroup renders a bordered group box containing a set of radio buttons from its Items collection. TTMSFNCRadioGroupPicker embeds the same group inside a dropdown popup, useful where screen space is limited. Both controls support HTML-formatted item text and anchor click events.

Adding items and reading the selection

Populate the Items collection and set ItemIndex to preselect an option. The OnRadioButtonClick event returns the index of the clicked item.

// Add items and select the first one
TMSFNCRadioGroup1.Items.Add('Option A');
TMSFNCRadioGroup1.Items.Add('Option B');
TMSFNCRadioGroup1.Items.Add('Option C');
TMSFNCRadioGroup1.ItemIndex := 0;

// React to a selection
procedure TForm1.TMSFNCRadioGroup1RadioButtonClick(Sender: TObject; AItemIndex: Integer);
begin
  Label1.Caption := 'Selected index: ' + IntToStr(AItemIndex);
end;

Multi-column layout and title checkbox

Use the Columns property to flow items into multiple columns. The Title sub-object exposes a ShowCheckBox option that places a checkbox in the title bar; setting CheckBoxMode to rgtcmToggleEnabled automatically enables or disables all radio buttons when the checkbox changes.

// Arrange items in two columns
TMSFNCRadioGroup1.Items.Add('Red');
TMSFNCRadioGroup1.Items.Add('Green');
TMSFNCRadioGroup1.Items.Add('Blue');
TMSFNCRadioGroup1.Items.Add('Yellow');
TMSFNCRadioGroup1.Columns := 2;
TMSFNCRadioGroup1.ItemIndex := 0;

// Title with optional checkbox that enables/disables the group
TMSFNCRadioGroup1.Title.Caption := 'Pick a color';
TMSFNCRadioGroup1.Title.ShowCheckBox := True;
TMSFNCRadioGroup1.Title.CheckBoxMode := rgtcmToggleEnabled;

This pattern is useful for optional sections in settings dialogs where the entire group can be toggled off.

Using TTMSFNCRadioGroupPicker with HTML and anchors

TTMSFNCRadioGroupPicker shows the radio group in a dropdown that opens when the control is clicked. HTML markup in items and OnRadioButtonAnchorClick let you embed hyperlinks inside individual option labels.

// TTMSFNCRadioGroupPicker drops down a radio group in a popup
TMSFNCRadioGroupPicker1.Items.Add('Small');
TMSFNCRadioGroupPicker1.Items.Add('Medium');
TMSFNCRadioGroupPicker1.Items.Add('Large');
TMSFNCRadioGroupPicker1.ItemIndex := 1;

// Combine HTML items with column layout and anchor click handling
TMSFNCRadioGroupPicker1.Items.Clear;
TMSFNCRadioGroupPicker1.Items.Add('<b>Economy</b> &ndash; standard delivery');
TMSFNCRadioGroupPicker1.Items.Add('<b>Express</b> &ndash; <a href="info">more info</a>');
TMSFNCRadioGroupPicker1.Columns := 1;

procedure TForm1.RadioGroupPickerRadioButtonAnchorClick(Sender: TObject;
  AItemIndex: Integer; AAnchor: string);
begin
  if AAnchor = 'info' then
    ShowMessage('Express delivers within 24 hours.');
end;

Combining the picker with HTML items and anchor events covers the common use case of options that need an inline help link without a separate label.

Combining items, multi-column layout, and the picker dropdown

Populate a two-column group, wire the click event, and also expose the same items in a compact picker control:

procedure TForm1.FormCreate(Sender: TObject);
var
  I: Integer;
begin
  // Shared items for both controls
  for I := 1 to 6 do
  begin
    TMSFNCRadioGroup1.Items.Add('Option ' + IntToStr(I));
    TMSFNCRadioGroupPicker1.Items.Add('Option ' + IntToStr(I));
  end;

  // Two-column layout with a toggleable title checkbox
  TMSFNCRadioGroup1.Columns := 2;
  TMSFNCRadioGroup1.Title.Text := 'Choose one';
  TMSFNCRadioGroup1.Title.ShowCheckBox := True;
  TMSFNCRadioGroup1.Title.CheckBoxMode := rgtcmToggleEnabled;
  TMSFNCRadioGroup1.ItemIndex := 0;
  TMSFNCRadioGroup1.OnRadioButtonClick := DoRadioClick;

  // Picker shows the same items in a dropdown
  TMSFNCRadioGroupPicker1.ItemIndex := 0;
end;

procedure TForm1.DoRadioClick(Sender: TObject; AItemIndex: Integer);
begin
  StatusBar1.Panels[0].Text := 'Selected: Option ' + IntToStr(AItemIndex + 1);
end;