加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

delphi – 如何将RadioButton分配给XE2中的RadioGroup?

发布时间:2020-12-15 09:08:56 所属栏目:大数据 来源:网络整理
导读:不要讨厌(或奉献)我这个愚蠢的问题,但我注意到XE2它已经改变,我试图将一个新的RadioButton放到RadioGroup,我注意到它实际上不是该组的一部分,为什么? 我需要写的是什么TStrings?对我来说这很难控制它. 解决方法 您无法手动将 TRadioButton添加到TRadioGrou
不要讨厌(或奉献)我这个愚蠢的问题,但我注意到XE2它已经改变,我试图将一个新的RadioButton放到RadioGroup,我注意到它实际上不是该组的一部分,为什么?

我需要写的是什么TStrings?对我来说这很难控制它.

解决方法

您无法手动将 TRadioButton添加到TRadioGroup. 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.

因此,您可以使用Object Inspector编辑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]);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读