用9个radiobutton在一个groupbox里面做了个小的控制端口,如何在选择radiobutton1的时候,让电脑知道需要发送的是“1”?求教,谢谢

解决方案 »

  1.   

    radiobutton1 的onclick事件判断 radiobutton1.checked 是否为True
      

  2.   

    你设置radiobutton1的caption属性为1,判断radiobutton1是否为选中状态,如果选中则传送radiobutton1的caption属性不就行了。
      

  3.   

    说错了,caption属性是显示,你设置它的name名称为radiobutton1的话,点击传送的时候截取它的那么属性的最后一个字符"1"行不。
      

  4.   

    总感觉你要实现的东西,做法不太对,你应该判断哪个radiobutton为选中状态,你想做的后面的程序不就是判断哪个选中吗?干嘛要传送"1"过去。
      

  5.   

    procedure TForm1.RadioButton1Click(Sender: TObject);
    begin
      if RadioButton1.Checked then ShowMessage('1');
    end;
      

  6.   

    我做的是一个放大器的控制窗口,需要对方大倍数1-9有点选择。我用了9个radiobutton,我的想法是先选择,然后点击一个发送button,然后就会执行的一个procedure senddata()。这个理念没错吧?
      

  7.   

    没有问题,你选择哪个控件,可以传个放大值就行了,在onclick事件中
      

  8.   

    放9个RadioButton控件,1个Botton控件
    在Botton的OnClick事件事加入以下代码procedure TForm1.Button1Click(Sender: TObject);
    var
    iBs:Integer;//倍数
    begin
      if RadioButton1.Checked then
        iBs:=1
      else if RadioButton2.Checked then
        iBs:=2
      else if RadioButton3.Checked then
        iBs:=3
      else if RadioButton4.Checked then
        iBs:=4
      else if RadioButton5.Checked then
        iBs:=5
      else if RadioButton6.Checked then
        iBs:=6
      else if RadioButton7.Checked then
        iBs:=7
      else if RadioButton8.Checked then
        iBs:=8
      else if RadioButton9.Checked then
        iBs:=9
      procedure senddata(iBs);
    end;
      

  9.   

    9种放大选择,每次只能是一种放大吧,换RadioGroup控件,在items添加9项数据,默认ItemIndex=0;
    senddata()函数加个参数,类型可以是integer或者string;则buttonClick代码:senddata(RadioGroup1.ItemIndex);//选中的按扭
    senddata(RadioGroup1.Items.Strings[RadioGroup1.ItemIndex]);//选中按扭显示的名称
      

  10.   

    设置每个RadioButton的tag为你要的数字,所有RadioButton用同一个onclick事件,
    事件中
    (变量名) := TRadioButton(Sender).tag;
      

  11.   


    正确!有RadioGroup组件不用户,非要整九个RadioButton ,这不没事找事吗!
      

  12.   

    我是4组分别有9种放大选项,也就是说每一组至少会要选择一种,每次发送至少得选择了4个放大倍数。如果用RadioButton选项,不就这36项里只能选一项了么?
      

  13.   

    用GroupBox + radioButton,就可以解决你说的这个问题。