The TRadioGroup Component


The TRadioGroup component is a perfect replacement for a TGroupBox component that only contains TRadioButton components. The main difference between the TGroupBox and the TRadioGroup components is that the TRadioGroup component can't act as a container. The TRadioGroup component can only contain radio buttons defined in its Items property.

image from book
Figure 14-17: The TRadioGroup component

Normally, to see if a radio button is selected, you have to test its Checked property. Since the radio buttons in a TRadioGroup aren't real radio buttons, you cannot check the Checked property of a certain radio button. To determine which radio button is selected in a TRadioGroup component, use the ItemIndex property.

Listing 14-21: Using TRadioGroup radio buttons

image from book
procedure TForm1.Button1Click(Sender: TObject); begin   if RadioGroup1.ItemIndex = -1 then   begin     MessageDlg('Select a radio button first.', mtWarning, [mbOK], 0);     Exit;   end;   with TForm.Create(Self) do   try     BorderStyle := TFormBorderStyle(RadioGroup1.ItemIndex);     Caption := RadioGroup1.Items[RadioGroup1.ItemIndex];     Position := poScreenCenter;     ShowModal;   finally     Free;   end; end;
image from book



Inside Delphi 2006
Inside Delphi 2006 (Wordware Delphi Developers Library)
ISBN: 1598220039
EAN: 2147483647
Year: 2004
Pages: 212
Authors: Ivan Hladni

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net