我想动态生成i(i值不能确定,根据程序中的计算结果得到的)个edit,我如何声明,如何生成呢,谢谢。。(100分)

  • 主题发起人 主题发起人 zhangqinghe
  • 开始时间 开始时间
Z

zhangqinghe

Unregistered / Unconfirmed
GUEST, unregistred user!
  大侠请出手,谢谢。。
 
var
ButtonList:array of TButton;
i,iCount:Integer;
iCount:=Screen.height;
SetLength(ButtonList,iCount);
for i:=0 to iCount-1 do
ButtonList:=TButton.Create(nil);
 
Edit不好玩,还是Button搞笑一些。。。
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TArrayEdit = array of tedit;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
n_edit : integer;
end;

var
Form1: TForm1;
tcreatedit : tarrayedit;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var

i : integer;
begin
setlength(tcreatedit,n_edit);
for i := low(tcreatedit) to high(tcreatedit) do
begin
tcreatedit := tedit.Create(self);
tcreatedit.Parent := self;
tcreatedit.SetBounds(30*i,30*i,50*i,50*i);
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
n_edit := 3;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
tcreatedit := nil;
end;

end.
 

Similar threads

后退
顶部