{
Die Eigenschaft Controls fuhrt alle untergeordneten Komponenten eines Steuerelements
(Hier z.B TRadioGroup) auf.
Controls ist hilfreich, wenn auf die untergeordneten Steuerelemente mit einer Zahl und
nicht mit ihrem Namen Bezug genommen werden soll.
So kann Controls beispielsweise verwendet werden, um in einer TRadioGroup Eigenschaften
der RadioButtons zu manipulieren (Hints anzeigen, verstecken,...)
}{
The property Controls lists all child controls of a Control.(Here a TRadioGroup)
Controls is an array of all the child controls.
The Controls property is convenient for referring to the children of a control
by number rather than name.
For example, Controls may be used to change properties of the Radiobuttons in a
TRadioGroup (showing hints, hiding items,...)
}{1. *******************************************************}// Deactivates/activates a specified item of a TRadioGroup // Deaktiviert/aktiviert in einer TRadioGroup ein bestimmtes Item procedure RGB_EnableItem(RadioGroup: TRadioGroup; ItemIndex: Byte; bEnabled: Boolean);
begin
RadioGroup.Controls[ItemIndex].Enabled := bEnabled;
end;
// Example: Deactivates the 2. Item (Index starts at 0) // Beispiel: 2. Item deaktivieren (Index beginnt bei 0) procedure TForm1.Button1Click(Sender: TObject);
begin
RGB_EnableItem(RadioGroup1, 1, False);
end;
{2. *******************************************************}// Hides/Shows a specified item of a TRadioGroup // Versteckt oder zeigt ein bestimmtes Item in einer TRadioGroup an. procedure RGB_ShowItem(RadioGroup: TRadioGroup; ItemIndex: Byte; bVisible: Boolean);
begin
RadioGroup.Controls[ItemIndex].Visible := bVisible;
end;
// Example: Hides the 2. Item (Index starts at 0) // Beispiel: 2. Item verstecken (Index beginnt bei 0) procedure TForm1.Button2Click(Sender: TObject);
begin
RGB_ShowItem(RadioGroup1, 1, False);
end;
{3. *******************************************************}// Show Hints for TRadioGroup items // Hints fur die Items in der TRadioGroup anzeigen procedure TForm1.Button3Click(Sender: TObject);
var
i: Byte;
beginfor i := 0 to RadioGroup1.ControlCount - 1 dobegin
RadioGroup1.Controls[i].ShowHint := True;
RadioGroup1.Controls[i].Hint := (Radiogroup1.Controls[i] as TRadiobutton).Caption;
end;
end;
{4. *******************************************************}// Focus a specified Radiobutton in a TRadioGroup // Ein bestimmter Radiobutton einer TRadioGroup fokussieren procedure RGB_FocusItem(RadioGroup: TRadioGroup; ItemIndex: Byte);
var
RadiogroupClick: TNotifyEvent;
beginif ItemIndex >= 0 thenbegin
RadioGroup.OnClick := nil;
(RadioGroup.Controls[1] as TRadiobutton).SetFocus;
RadioGroup.OnClick := RadiogroupClick;
end;
end;
// Example: Focus the 2. Radiobutton // Beispiel: Den 2. Radiobutton fokussieren procedure TForm1.Button4Click(Sender: TObject);
begin
RGB_FocusItem(RadioGroup1, 1);
end;
Если Вас заинтересовала или понравилась информация по разработке на Delph - "Получить доступ к элементам TRadioGroup", Вы можете поставить закладку в социальной сети или в своём блоге на данную страницу: Так же Вы можете задать вопрос по работе этого модуля или примера через форму обратной связи, в сообщение обязательно указывайте название или ссылку на статью!