unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
ComboBox1: TComboBox;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
EditCount: Integer;
implementation
var
ArrEdit: array of TEdit;
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
begin
SetLength(ArrEdit, EditCount);
for i := Low(ArrEdit) to High(ArrEdit) do
begin
ArrEdit := TEdit.Create(nil);
ArrEdit.Parent := self;
ArrEdit.Name := 'Edit'+ IntToStr(i + 1);
ArrEdit.Left := i * ArrEdit.Width;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ShowMessage(ArrEdit[0].Text);
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
var
i: Integer;
begin
for i := Low(ArrEdit) to High(ArrEdit) do
begin
ArrEdit.Free;
end;
EditCount := StrToInt(ComboBox1.Items[ComboBox1.ItemIndex]);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
EditCount := 0;
end;
end.