表单中有多个Button,怎么最好的判断其中哪个被选中?而如果有一个字符=‘10’;怎样就对Button10进行处理?

解决方案 »

  1.   

    第一个问题,可以通过判断来作,
    if Button1.Focused=true then
    begin
    end;第二个问题,可以用case语句来作吧,哈哈。
      

  2.   

    1、for i := 0 to self.ComponentCount - 1 do 
      if (self.Components[i] is TButton)and
        (TButton(self.Components[i]).Focused) then
         showmessage(TButton(self.Components[i]).Name);
      

  3.   

    2、var
         s: string;
         AButton : TButton;
    begin
      s := '10';
      AButton  := self.FindComponent('Button'+s) as TButton;
    end;//你测试一下吧,我还没来得及测试