递归调用生成动态按钮,像一个树一样,比如:
    a
    --aa1
    --aa2
    b
    --bb1
    --bb2
生成按钮的排布为:a aa1 aa2
                  b bb1 bb2
用递归调用生成

解决方案 »

  1.   

    不是生成动态按钮,是动态生成按钮BUTTON
      

  2.   

    固定是2行3列吗
    a aa1 aa2
    b bb1 bb2
      

  3.   

    procedure CreateNextButton(row,col:integer);
    var
      Button: TButton;
    begin  //这里是创建按钮的代码
      Button := TButton.create(self);
      ...
      //
      Button.top := row*20;  //这里加个固定值的话就是按值间隔
      Button.Left := col*50;  inc(row);
      inc(col);
      if (row>2) and (col>3) then exit;//设为2行3列
      
      CreateNextButton(row,col);
    end;
    第一次调用是 CreateNextButton(0,0);没环境调试,可能会有点小错误...
      

  4.   

    上面错了,改为以下
    procedure CreateNextButton(row,col:integer);
    var
      Button: TButton;
    begin  //这里是创建按钮的代码
      Button := TButton.create(self);
      ...
      //
      Button.top := row*20;
      Button.Left := col*50;  if col<3 and row<2 then
        inc(col)
      else begin
        inc(row);
        col := 0;
      end;  if (row>=2) or (col>=3) then exit;//设为2行3列
      
      CreateNextButton(row,col);
    end;
      

  5.   

    我现在是想把一棵树转全部换成按钮,按钮还要显示节点的TEXT
    但是还是要谢谢你给了我思路
      

  6.   

    logne()
    就是把节点换成按钮