Sign in Join
Wiki copytemporary

Revision 1 of 2, by Bart on 4-17-2022. The page as it is now.

TRadioGroup

A TRadioGroup 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.

Usage

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.

Small example

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


From the Free Pascal wiki, page "TRadioGroup", as it stood on 2022-04-17 after a change by Bart, out of the wiki's dump of 2024-05-26. 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.