我想做个循环语句
让button1到buttoni的caption依次为1到i
该怎么表示某个button?

解决方案 »

  1.   

    用tag来表示吧,设置好了,就可以用了,
      

  2.   

    写一个公共的procedure来判断sender
      

  3.   

    var i,j :Integer;
    begin
    j:=0;
    for i:=0 to form1.ComponentCount -1 do
    begin
      if form1.Components[i] is TButton then
      begin
        inc(j);
        showmessage((form1.Components[i] as TButton).Name );
        (form1.Components[i] as TButton).Caption  := Inttostr(j);
      end;
    end;end;
      

  4.   

    那请问窗体里Tbutton的数量怎么表示?
      

  5.   

    var i,j :Integer;
    begin
    j:=0;
    for i:=0 to form1.ComponentCount -1 do
    begin
      if form1.Components[i] is TButton then
      begin
        inc(j);
        showmessage((form1.Components[i] as TButton).Name );
        (form1.Components[i] as TButton).Caption  := Inttostr(j);
      end;
    end;
    SHowmessage(Inttostr(j));//tbutton数量end;
      

  6.   

    button1.tag可以赋值Int,自己作为标记用的