[Overview][Constants][Types][Classes][Procedures and functions][Index] Reference for unit 'StdCtrls' (#lcl)

TRadioButton

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

TRadioButton : a button that works with other Radio Buttons in a mutually exclusive way - if one button is selected, none of the others in the group can be selected

Declaration

Source position: stdctrls.pp line 1320

type TRadioButton = class(TCustomCheckBox)

  class procedure WSRegisterClass; override;

  

WSRegisterClass - Register this Class for the current Widget Set

protected

  procedure ApplyChanges; override;

  

ApplyChanges - method for applying specified changes

  function DialogChar(); override;

  

DialogChar - a LCL Key Message; returns True if a Dialog character has an associated message

  procedure RealSetText(); override;

  

Procedure to store text associated with the control in a string

  procedure DoClickOnChange; override;

  procedure CreateParams(); override;

public

  constructor Create(); override;

  

Create - constructor for TRadioButton: calls inherited Create then initialises style

published

  property Align;

  

Used to align the control to the top, bottom, left or right of its client.

  property Anchors;

  

The set of anchor definitions for this control

  property AutoSize;

  

Whether auto-size is to be used

  property BidiMode;

  

BiDiMode - enabling bi-directional writing

  property BorderSpacing;

  

Determines the border spacing for this control

  property Caption;

  

Caption - the text-string appearing on the Control, usually used to identify its function

  property Checked;

  

Checked - whether this button has been checked, which signifies selection

  property Color;

  

Determine the colour for the current control

  property Constraints;

  

Determine Constraints (max and min height and width) for this control

  property DragCursor;

  

DragCursor - the style of cursor to be used during the Drag process

  property DragKind;

  

DragKind - what sort of dragging? Drag or Dock

  property DragMode;

  

DragMode - whether manual or automatic

  property Enabled;

  

Whether the control is Enabled (read/write). If not, it usually appears 'greyed-out'

  property Font;

  

The font to be used for text in this control (read/write).

  property Hint;

  

Hint - a small informative pop-up box that appears when the mouse 'hovers' over a control

  property OnChange;

  

OnChange - event handler for any change in properties of the control

  property OnChangeBounds;

  

Event handler for a change in bounds of the control

  property OnClick;

  

Event Handler for mouse click

  property OnContextPopup;

  

Event handler to supply information when a context-sensitive pop-up menu is required

  property OnDragDrop;

  

Event handler for the drop of a control onto this control.

  property OnDragOver;

  

Event handler for the case when a control is dragged over another control

  property OnEndDrag;

  

Event handler for the end of a dragging process

  property OnEnter;

  

OnEnter - event handler for when the mouse enters the control, and the control receives focus

  property OnExit;

  

OnExit - event handler for when the mouse leaves the control and it loses focus

  property OnKeyDown;

  property OnKeyPress;

  property OnKeyUp;

  property OnMouseDown;

  

Event handler for when a mouse button is pressed down

  property OnMouseEnter;

  

Event handler for when the mouse enters the area of the current control

  property OnMouseLeave;

  

Event handler for when the mouse leaves the area of the current control

  property OnMouseMove;

  

Event handler for mouse movement within the current control

  property OnMouseUp;

  

Event handler for when the mouse button is released, ie "up"

  property OnResize;

  

Event Handler for resize of control

  property OnStartDrag;

  

Event handler for start of dragging operation

  property ParentBidiMode;

  

ParentBiDiMode - does the control follow the BiDiMode settings of its parent?

  property ParentColor;

  

ParentColor - should the control have the same colour as the parent? Default is true

  property ParentFont;

  

ParentFont - should the control use the same font as the parent? Default is true

  property ParentShowHint;

  

ParentShowHint - does the control adopt the same hinting behaviour as its parent? Default is true

  property PopupMenu;

  

PopupMenu - a context-sensitive menu that pops up when the right mouse button is clicked over this control

  property ShowHint;

  

Flag to determine: Is hint to be displayed for this control?

  property TabOrder;

  

The place this control occupies in the list of tabs

  property TabStop;

  

Is the control in the sequence of controls accessed by successive presses of the Tab key?

  property Visible;

  

Visible - can the control be seen?

end;

Inheritance

TRadioButton

  

TRadioButton : a button that works with other Radio Buttons in a mutually exclusive way - if one button is selected, none of the others in the group can be selected

|

TCustomCheckBox

  

TCustomCheckBox is the ancestor of all check-box components.

|

TButtonControl

  

TButtonControl : ancestor class for several Button (including Radio Button) and Check Box classes

|

TWinControl

|

TControl

|

TLCLComponent

  

TLCLComponent - base class for LCL components

|

TComponent,IUnknown,IInterfaceComponentReference

|

TPersistent

|

TObject

Description

TRadioButton : a button that works in conjunction with other Radio Buttons in a mutually exclusive manner - if one button of a group is selected, none of the others in that group can be selected.

The Application Programmer is responsible for ensuring that the OnClick event handler for each button has a unique Action, and that the Actions of the other (deselected and therefore inactive) buttons are turned off.

TRadioGroup behaves differently from a group of TRadioButton controls placed arbitrarily around a form.

In the case of TRadioButton, the mutual exclusivity is a feature that applies to any RadioButton anywhere in the Form, and the RadioButtons can be rearranged in any order or placed anywhere within the containing Form, while in TRadioGroup the exclusivity applies only to buttons within the Group, which are ordered strictly according to their ItemIndex within the Items stringlist.

TRadioButton is an entity in itself, with a number of additional properties, whereas the buttons within TRadioGroup are not separate entities, but rather are simply entries in a list of strings, each of which is associated with the on-screen image of a RadioButton.

The example shows the difference between the use of TRadioButton and TRadioGroup

See also

HowToUseStdCtrls

  

How to use StdCtrls, ComCtrls or ExtCtrls

TRadioGroup

  

TRadioGroup : A group of related but mutually exclusive radio buttons, requiring the user to select one af a set of alternatives

Example

{Using TRadioGroup with three entries in Items:
Index 0: Red
Index 1: Amber
Index 2: Green}

procedure TTrivialForm1.RadioGroup1Click(Sender: TObject);
begin
  case RadioGroup1.ItemIndex of
  0:   Shape1.brush.color := clRed;
  1:   Shape1.brush.color := clYellow;
  2:   Shape1.brush.color := clGreen
  end
end;



{Using three separate RadioButtons}

procedure TForm1.RadioButton1Click(Sender: TObject);
begin
  Shape1.brush.color := clRed
end;

procedure TForm1.RadioButton2Click(Sender: TObject);
begin
  Shape1.brush.color := clYellow
end;

procedure TForm1.RadioButton3Click(Sender: TObject);
begin
  Shape1.brush.color := clGreen
end;
The latest version of this document can be found at lazarus-ccr.sourceforge.net.