var tmp: TEdit; begin tmp := TEdit.create(self); tmp.parent := self; tmp.left := 10; tmp.top := 10; tmp.text := inttostr(strtoint(Combobox1.text)*2); end;
var Edit:TEdit; i:integer; begin For i:=1 to StrtoInt(ComboBox1.text)*2 do begin Edit:=TEdit.Create(self); Edit.Parent:=self; Edit.Name:='Edit'+InttoStr(i); Edit.Left:=20; Edit.Top:=20*i; end; end;
o 先定义 edtArray:array of Tedit; 再 setlength(edtArray, ComboBox1.Items.Count) 最后跟楼上一样创建
setlength(edtArray, ComboBox1.Items.Count*2) for i = 0 to ComboBox1.Items.Count*2-1 begin edtArray[i]:=TEdit.Create(self); edtArray[i].Parent:=self; edtArray[i].Left:=20; edtArray[i].Top:=20*i; end
tmp: TEdit;
begin
tmp := TEdit.create(self);
tmp.parent := self;
tmp.left := 10;
tmp.top := 10;
tmp.text := inttostr(strtoint(Combobox1.text)*2);
end;
begin
For i:=1 to StrtoInt(ComboBox1.text)*2 do
begin
Edit:=TEdit.Create(self);
Edit.Parent:=self;
Edit.Name:='Edit'+InttoStr(i);
Edit.Left:=20;
Edit.Top:=20*i;
end;
end;
楼上的so快..tmp.left := 10;
tmp.top := 10; // 建议你不要取绝对数值 还是取相对某个值的号
比如tmp.left := Combobox1.Left ;
tmp.top := Combobox1.Top + 30;
tmp.text := inttostr(strtoint(Combobox1.text)*2);
先定义
edtArray:array of Tedit;
再
setlength(edtArray, ComboBox1.Items.Count)
最后跟楼上一样创建
for i = 0 to ComboBox1.Items.Count*2-1
begin
edtArray[i]:=TEdit.Create(self);
edtArray[i].Parent:=self;
edtArray[i].Left:=20;
edtArray[i].Top:=20*i;
end