求教关于radiogroup的用法

chdaner 2009-08-27 04:24:36
在radiogroup1 里面,放三个radiobutton, caption分别是a,b,c
怎么知道选中的是哪个?
即点击一个button按钮,将选中的caption显示在label.caption上
...全文
457 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
dinoalex 2009-08-27
  • 打赏
  • 举报
回复
最好是加上 if RadioGroup1.ItemIndex > 0 then ...
reverzeng 2009-08-27
  • 打赏
  • 举报
回复
楼上正解
bdmh 2009-08-27
  • 打赏
  • 举报
回复

var
s:string;
begin
s := RadioGroup1.Items.Strings[RadioGroup1.ItemIndex];
ShowMessage(s);
end;
chdaner 2009-08-27
  • 打赏
  • 举报
回复
楼上的兄台,这个方法是可以,但是我是有四十个radiogroup,八十个radiobutton
取四十个选中的项上传到数据库,能不能直接取radiogroup中选中的值?
7年 2009-08-27
  • 打赏
  • 举报
回复
if radiobutton1.Checked then
label1.Caption:=radiobutton1.Caption;
if radiobutton2.Checked then
label1.Caption:=radiobutton2.Caption;
if radiobutton3.Checked then
label1.Caption:=radiobutton3.Caption;
chdaner 2009-08-27
  • 打赏
  • 举报
回复
楼上的大哥,你这个句子我为什么就写不出来,

Label1.Caption := RadioGroup1.Items.Strings[RadioGroup1.Item];

只能写成这样,后面不能加index,加了出错
songtreer 2009-08-27
  • 打赏
  • 举报
回复
Label1.Caption := RadioGroup1.Items.Strings[RadioGroup1.ItemIndex];
chdaner 2009-08-27
  • 打赏
  • 举报
回复
是说 label1.caption:=radiogroup1.itemindex 吗?这样不行啊

最多只能写成label1.caption:=radiogroup1.item ,后面就没了。
de410 2009-08-27
  • 打赏
  • 举报
回复
RadioGroup1.ItemIndex
starluck 2009-08-27
  • 打赏
  • 举报
回复
Itemindex

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧