我用 8个TspeedButton按纽定义了一组按纽,如何检测当前按下的是哪个TspeedButton呢?

解决方案 »

  1.   

    for i:=0 to self.ComponentCount-1 do
      begin
        if components[i] is Tspeedbutton then
          if Tspeedbutton(components[i]).GroupIndex=1 then
             if Tspeedbutton(components[i]).Down=true then
             //dosomething
      end;
    end;
      

  2.   

    8个按纽同时指向一个ONCLICK事件。
    代码如下:
    procedure TForm1.SpeedButton1Click(Sender: TObject);
    begin
      Showmessage(TSpeedButton(Sender).Name);
    end;按一下那个按纽就把该按纽的名字SHOWMessage出来!