form上面放了10个radiobuttion,分别叫radiobuttion1 到9,怎么才能变成一个数组呢
谢谢

解决方案 »

  1.   

    先遍历窗体上的所有控件,不好意思,语句忘了,然后
     if sender is Tradiobuttion then 判断
       // 在这里给数组付值
      

  2.   

    就没有办法在form上摆控件的时候就把相关的设为一个数组吗
    我记得是可以的,只是两年不用,忘完了
      

  3.   

    .tag 属性可以用于控件数组的使用。另外可以将控件的名称命名为 RBtn1 Rbtn2 RBtn3 ....然后使用FindComponent函数调用它们。例如:var i:integer;
    obj:TObject;
    begin
      for i:=1 to 10 do 
        begin
          obj:=findcomponent('RBtn'+inttostr(i));
          .....
      

  4.   

    .tag 的使用:var i:integer;
    obj:Tobject;
    begin
    for i:=0 to ComponentCount -1 do
      if (components[i].tag =10) and (components[i] is RadioButton) then
         begin
           obj:=components[i];
           ........
      

  5.   

    不好意思,  component[i] is RadioButton) 应该修改为component[i] is TRadioButton)
      

  6.   

    if sender is TRadioButton then 
      case    TRatioButton(sender).tag of
       1:
       2:
      end;
      

  7.   

    procedure TFrmTest.ChuangTiBiaoGeCreate();
    var
    NewCheckBoxtTop:integer;
    i:integer;
    begin
      filename:=ExtractFilePath(paramstr(0))+'DBPZLIST.ini';
      peizhilist:=Tinifile.create(filename);
      NewCheckBoxtTop:=0;
      for i:=1 to 30 do
        begin
        NEWCheckBox[i]         := TcheckBox.create(self);
        NEWCheckBox[i].top     := NewCheckBoxtTop+20 ;
        NEWCheckBox[i].Left    := 8;
        NEWCheckBox[i].Width   := 70;
        NEWCheckBox[i].Caption := DBGrid.Columns[i].Title.Caption  ;
        Newcheckbox[i].Parent  := GroupBox ;
        NewCheckBox[i].Checked := peizhilist.readbool('pz',NEWCheckBox[i].Caption,false);
        DBGrid.Columns[i].Visible :=newcheckbox[i].Checked ;
        NewCheckBoxtTop        := NewCheckBoxtTop+20;    end;
    end;
      

  8.   

    接上文,你自己参考一下吧
    ...
    var
      NEWCheckBox: array[0..30] of TCheckBox ;//在前面声明一个数组
    implementation
    ....
      

  9.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
      for I := 0 to Self.ComponentCount - 1do
      begin
        if (Self.FindComponent('StaticTextN')) is TStaticText then
        begin
          ((Self.FindComponent('StaticTextN')) as TStaticText).Caption := 'Caption';
          ((Self.FindComponent('StaticTextN')) as TStaticText).Left := 100;
          ((Self.FindComponent('StaticTextN')) as TStaticText).Top := 200;
          //保存到数据库
        end;
      end;
    end;------------------------------------
    这个例子可以看看,另外可以用tag属性
      

  10.   

    本身就在一个数组里,可以用findcomponent或者components[]循环
    用tag做下标也行