Form中有四个checkbox对象,我想在Click事件调用一过程GetInfo(chkIndex)。
在过程中如何才能根据参数chkIndex来映射到四个checkbox对象?(chckboxName + chkIndex),这样是一个字符串,我想让它是一个变量。如何做到?望前辈指点一二。谢谢

解决方案 »

  1.   

    顺手嘛,不给分的比给10分的多的多。方法有很多,介绍一个:procedure TForm1.getinfo(const cname:string);
    var
      tt:TCheckBox;
    begin
      tt:=TCheckBox(FindComponent(cname));
      if tt<>nil then
      with tt do
      begin
        ....//你的操作
      end;
    end;
      

  2.   

    感谢楼上狼兄,方法没错,我还想知道DELPHI动态变量的用法啊。
      

  3.   

    procedure TForm1.Button2Click(Sender: TObject);
    begin
        TCheckBox(self.FindComponent('CheckBox1')).Checked:=not TCheckBox(self.FindComponent('CheckBox1')).Checked;
    end;