interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Menus;type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
procedure N1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
ledit_name:array[1..200] of TLabeledEdit; //名称
//ledit_left:array[1..200] of TLabeledEdit;//左边坐标
//ledit_right:array[1..200] of TLabeledEdit;//右边坐标
i:integer=0;
implementation{$R *.dfm}procedure TForm1.N1Click(Sender: TObject);
var l:integer;
begin
if i=200 then
exit;
i:=i+1;
l:=30; //左边
ledit_name[i]:=TLabeledEdit.Create(nil); //生成控件LabeledEdit
with ledit_name[i] do //设置控件
begin
LabelPosition:=lpLeft; //设置LABEL在左边
EditLabel.Caption:=inputbox('请输入','元素名称','');
if i=1 then
begin
Top:=10;
Left:=l;
end else begin //设置LabeledEdit控件的位置
Top:=(10+Width)*i;
Left:=l;
end;
end;
end;
//没有任务错误提示就是想点一下菜单生成一个 LabeledEdit控件 放在上一个的下面间隔10含像素点
1 创建控件没指定parent
2 如果1没起作用尝试设定控件宽高和visible属性
3 如果以上都没起作用,把控件bringtofront
另外记得释放数组
要得到上一个控件的top位置,才能在它的下方10个像素放新控件
。。写这东西的时候一直想不起来。
那个高度也弄成了宽度了。OH。--!