首页 > 代码库 > 动态创建组件TEdit

动态创建组件TEdit

//动态创建组件TEdit 

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  Edit:TEdit;
begin
  Edit:=Tedit.Create(nil);
  Edit.parent :=Self;
  Edit.Show;
  Edit.Left := x;
  Edit.Top := y;
end;
{ tedit1 }
procedure TForm1.FormDestroy(Sender: TObject);
var
  i:integer;
begin
  try
    for i:=0 to self.ComponentCount-1 do
    begin
      if self.Components[i] is TEDIT then
        TEDIT(self.Components[i]).Free;
    end;
  except
    exit;
  end;
end;


来自为知笔记(Wiz)