You are hereHow to access a TRadioButton from a TRadioGroup in Delphi 2005

How to access a TRadioButton from a TRadioGroup in Delphi 2005


By Mel - Posted on 28 October 2009

In Borland Developer Studio (Delphi 2005), the TRadioGroup component is used to easily create and manage a set of radio buttons on design-time. You can add radio buttons to the TRadioGroup by just opening the object inspector pane and editing the Items property of the TRadioGroup. The strings you add to the Items property represent the captions of the radio buttons that appear automatically within the TRadioGroup. As shown in the following image, the strings "Item1", "Item2", and "Item3" that were added to the Items property via the object inspector (left pane) appear as captions of the radio buttons on the Form.

However, the TRadioGroup does not provide a way to access the other properties of its radio buttons from the object inspector pane on design-time. This has lead some to assume that only the captions of the radio buttons can be modified. Of course, this assumption is incorrect because one can still access the radio buttons programmatically.

The radio buttons can be accessed through the Controls property of the TRadioGroup. The Controls property is an array inherited from the TWinControl class. To access a specific radio button from the TRadioGroup, you just use its index to get the particular element of the Controls array.

  1. RadioGroup1.Controls[1].Enabled := False;

The above sample code disables the second radio button in RadioGroup1 as shown in the following image.

Nice site, bro. We have similarities... We're member of the same church and we develop software using the same tool which is Delphi. I saw your other blog entries and all I could say is "job well done..."

Rajeem Eid Cariazo

Hi Bro. Rajeem, thanks for visiting this site.

- Mel

Post new comment

The content of this field is kept private and will not be shown publicly.
Image CAPTCHA
Enter the characters shown in the image.