Sign in Join
Wiki copytemporary

TRadioGroup

Deutsch · English · Français · Suomi · Русский · 日本語

Comparison of several TRadioButton and a TRadioGroup with the characteristical properties given in the infobox.

TRadioGroup tradiogroup.png is a group of related but mutually exclusive TRadioButtons, requiring the user to select one of a set of alternatives. It's like a TGroupBox with integrated TRadioButtons. To use a TRadioGroup on a form, you can simply select it on the Standard tab of the Component Palette and place it by clicking on the form.

TRadioGroup manages its items as a TStrings list in the Items property. The Object Inspector provides a small text input where each line represents one entry in the radio group box.
With the Columns property the layout can be easily adapted to a column-layout. The property ColumnLayout allows choosing the insertion direction "horizontal then vertical" or vice versa.
The currently selected item is not determined via a checked property as the TRadioButton provided, instead an ItemIndex is used here. -1 is equal to "no selection", 0 selects the first option, 1 the second and so forth. ItemIndex is both readable and writable.
The caption of the group can be changed by using the Caption property. Changes on the Font property influence the caption as well as the text of the items inside the box.

Code Examples:

pascal
// Configuration:
    with RadioGroup1 do
    begin
      caption := 'My Group 1';
      itemIndex := 0;
      font.size := 12;
    end;
    
    // Conditional Check:
    if RadioGroup1.ItemIndex = 0 then
    begin
       ...
    end;
    
    // Conditional Check with Case:
    case RadioGroup1.ItemIndex of
      0: begin  
            firstOption;  
            ...
          end;
      1: begin
            secondOption;
            ...
          end;
      2: thirdOption;
      3: fourthOption;
      ...
    end;

Examples

Drawing random shapes on a form

Example screenshot of the finished program.

Geometric figures should be drawn randomly and depending on the TRadioGroups to the form. The first RadioGroup determines the shape, the second RadioGroup detrmines the number.

pascal
procedure TForm1.rgShapeClick(Sender: TObject);
    begin
      Repaint;
    end;
pascal
procedure TForm1.FormPaint(Sender: TObject);
    var
      i: Integer;
    begin
      if TryStrToInt(rgCount.Items[rgCount.ItemIndex], i) then
        for i:=1 to i do begin
          Canvas.Pen.Color:=Random($1000000);
          Canvas.Brush.Color:=Random($1000000);
          case rgShape.Items[rgShape.ItemIndex] of
            'Lines':      Canvas.Line(Random(ClientWidth), Random(ClientHeight), Random(ClientWidth), Random(ClientHeight));
            'Rectangles': Canvas.Rectangle(Random(ClientWidth), Random(ClientHeight), Random(ClientWidth), Random(ClientHeight));
            'Ellipses':   Canvas.Ellipse(Random(ClientWidth), Random(ClientHeight), Random(ClientWidth), Random(ClientHeight));
          end;
        end;
    end;

See also

LCL Components Component Tab Components
Standard TMainMenu • TPopupMenu • TButton • TLabel • TEdit • TMemo • TToggleBox • TCheckBox • TRadioButton • TListBox • TComboBox • TScrollBar • TGroupBox • TRadioGroup • TCheckGroup • TPanel • TFrame • TActionList
Additional TBitBtn • TSpeedButton • TStaticText • TImage • TShape • TBevel • TPaintBox • TNotebook • TLabeledEdit • TSplitter • TTrayIcon • TControlBar • TFlowPanel • TMaskEdit • TCheckListBox • TScrollBox • TApplicationProperties • TStringGrid • TDrawGrid • TPairSplitter • TColorBox • TColorListBox • TValueListEditor
Common Controls TTrackBar • TProgressBar • TTreeView • TListView • TStatusBar • TToolBar • TCoolBar • TUpDown • TPageControl • TTabControl • THeaderControl • TImageList • TPopupNotifier • TDateTimePicker
Dialogs TOpenDialog • TSaveDialog • TSelectDirectoryDialog • TColorDialog • TFontDialog • TFindDialog • TReplaceDialog • TTaskDialog • TOpenPictureDialog • TSavePictureDialog • TCalendarDialog • TCalculatorDialog • TPrinterSetupDialog • TPrintDialog • TPageSetupDialog
Data Controls TDBNavigator • TDBText • TDBEdit • TDBMemo • TDBImage • TDBListBox • TDBLookupListBox • TDBComboBox • TDBLookupComboBox • TDBCheckBox • TDBRadioGroup • TDBCalendar • TDBGroupBox • TDBGrid • TDBDateTimePicker
Data Access TDataSource • TCSVDataSet • TSdfDataSet • TBufDataset • TFixedFormatDataSet • TDbf • TMemDataset
System TTimer • TIdleTimer • TLazComponentQueue • THTMLHelpDatabase • THTMLBrowserHelpViewer • TAsyncProcess • TProcessUTF8 • TProcess • TSimpleIPCClient • TSimpleIPCServer • TXMLConfig • TEventLog • TServiceManager • TCHMHelpDatabase • TLHelpConnector
Misc TColorButton • TSpinEdit • TFloatSpinEdit • TArrow • TCalendar • TEditButton • TFileNameEdit • TDirectoryEdit • TDateEdit • TTimeEdit • TCalcEdit • TFileListBox • TFilterComboBox • TComboBoxEx • TCheckComboBox • TButtonPanel • TShellTreeView • TShellListView • TXMLPropStorage • TINIPropStorage • TJSONPropStorage • TIDEDialogLayoutStorage • TMRUManager • TStrHolder
LazControls TCheckBoxThemed • TDividerBevel • TExtendedNotebook • TListFilterEdit • TListViewFilterEdit • TLvlGraphControl • TShortPathEdit • TSpinEditEx • TFloatSpinEditEx • TTreeFilterEdit • TExtendedTabControl •
RTTI TTIEdit • TTIComboBox • TTIButton • TTICheckBox • TTILabel • TTIGroupBox • TTIRadioGroup • TTICheckGroup • TTICheckListBox • TTIListBox • TTIMemo • TTICalendar • TTIImage • TTIFloatSpinEdit • TTISpinEdit • TTITrackBar • TTIProgressBar • TTIMaskEdit • TTIColorButton • TMultiPropertyLink • TTIPropertyGrid • TTIGrid
SQLdb TSQLQuery • TSQLTransaction • TSQLScript • TSQLConnector • TMSSQLConnection • TSybaseConnection • TPQConnection • TPQTEventMonitor • TOracleConnection • TODBCConnection • TMySQL40Connection • TMySQL41Connection • TMySQL50Connection • TMySQL51Connection • TMySQL55Connection • TMySQL56Connection • TMySQL57Connection • TSQLite3Connection • TIBConnection • TFBAdmin • TFBEventMonitor • TSQLDBLibraryLoader
Pascal Script TPSScript • TPSScriptDebugger • TPSDllPlugin • TPSImport Classes • TPSImport DateUtils • TPSImport ComObj • TPSImport DB • TPSImport Forms • TPSImport Controls • TPSImport StdCtrls • TPSCustomPlugin
SynEdit TSynEdit • TSynCompletion • TSynAutoComplete • TSynMacroRecorder • TSynExporterHTML • TSynPluginSyncroEdit • TSynPasSyn • TSynFreePascalSyn • TSynCppSyn • TSynJavaSyn • TSynPerlSyn • TSynHTMLSyn • TSynXMLSyn • TSynLFMSyn • TSynDiffSyn • TSynUNIXShellScriptSyn • TSynCssSyn • TSynPHPSyn • TSynTeXSyn • TSynSQLSyn • TSynPythonSyn • TSynVBSyn • TSynAnySyn • TSynMultiSyn • TSynBatSyn • TSynIniSyn • TSynPoSyn
Chart TChart • TListChartSource • TRandomChartSource • TUserDefinedChartSource • TCalculatedChartSource • TDbChartSource • TChartToolset • TChartAxisTransformations • TChartStyles • TChartLegendPanel • TChartNavScrollBar • TChartNavPanel • TIntervalChartSource • TDateTimeIntervalChartSource • TChartListBox • TChartExtentLink • TChartImageList
IPro TIpFileDataProvider • TIpHtmlDataProvider • TIpHttpDataProvider • TIpHtmlPanel
Virtual Controls TVirtualDrawTree • TVirtualStringTree • TVTHeaderPopupMenu

From the Free Pascal wiki, page "TRadioGroup", as the Internet Archive kept it on 2025-06-16, last changed on 2024-11-22. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 2, last changed by WikiArchive .

Edited on wiki.freepascal.org by 5 people, 2013–2022

From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.

WhenWhoWhat changed
Rfc1394Created page
Rfc1394 (minor)
MichlPreparation for translation
Michl
MichlDescription (minor)
Michl"Usage" added
Arent
Arent
Arent
Djzepi
BartSmall example: language

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.