我有36个TSpeedButton按纽,它们的Caption分别为'0'..'9'和'A'..'Z'数值和字母,
当我点击其中的一个speedbutton时,要把它的Caption赋值给一个Edit,应该怎么写事件赋值?

解决方案 »

  1.   

    选中所有SpeedButton按钮,在上面双击,这样所有SpeedButton都指向下面这个事件,
    在里面写如下代码:
    procedure TForm1.SpeedButton1Click(Sender: TObject);
    begin
      Edit1.Text := (Sender as TSpeedButton).Caption;
    end;
      

  2.   

    for i:=0 to component-1 do
    if (component[i] is tspeedbutton) then
      edit:= tspeedbutton(component[i]).caption;
      

  3.   

    选中所有SpeedButton按钮,在OnClick上面双击,...
      

  4.   

    var
      i:integer;
    begin 
    with Form do
      for i := 0 to ComponentCount-1 do
        if (Components[i] is TSpeedButton) then
          (Components[i] as TSpeedButton).OnClick:=DoButtonClick
    end;procedure TForm1.DoButtonClick(Sender: TObject);
    begin
      Edit.Text:=(Sender as TSpeedButton).Caption;
    end;
      

  5.   

    Edit1.Text := (Sender as TSpeedButton).Caption;
      

  6.   

    嘿嘿,又从死树兄那儿学了一招,可怜俺以前都是把每个的onclick选为onbutton1click...,自卑中...
      

  7.   

    to thinkcat(思想猫):怎么知道您的i值?
      

  8.   

    是一个循环的,是判断哪个SpeedButton被click。
    循环到哪个被Click,i就是几