gpt4 book ai didi

delphi - 如何在 XE2 中将 RadioButton 分配给 RadioGroup?

转载 作者:行者123 更新时间:2023-12-03 15:39:51 26 4
gpt4 key购买 nike

不要讨厌(或专注)我这个愚蠢的问题,但我注意到 XE2 上它已经改变了,我尝试将一个新的 RadioButton 放入 RadioGroup 中,我发现它实际上不属于该组,为什么?

我需要写什么 TStrings ?对我来说,这样控制有点困难。

最佳答案

您无法手动添加 TRadioButton到 TRRadioGroup。 TRadioGroup控制一直以这种方式进行。您必须使用其 Items 属性来添加单选按钮。

Embarcadero 文档说

To add radio buttons to a TRadioGroup, edit the Items property in the Object Inspector. Each string in Items makes a radio button appear in the group box with the string as its caption. The value of the ItemIndex property determines which radio button is currently selected.

因此,您可以使用对象检查器来编辑 Items 属性或编写如下代码:

RadioGroup1.Items.Add('Option 1');
RadioGroup1.Items.Add('Option 2');
RadioGroup1.Items.Add('Option 3');
RadioGroup1.Items.Add('Option 4');
RadioGroup1.Items.Add('Option 5');

最后,要检查选择了哪个单选按钮,请使用 ItemIndex 属性,如下所示

if RadioGroup1.ItemIndex>=0 then
ShowMessage(RadioGroup1.Items[RadioGroup1.ItemIndex]);

关于delphi - 如何在 XE2 中将 RadioButton 分配给 RadioGroup?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16154262/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com