Cita:
Empezado por YolandaM
Necesito crear dinamicamente en una form x paneles con sus labels y sus edits.
|
Programa un botón conel siguiente código:
Código Delphi
[-]
procedure TForm1.Button1Click(Sender: TObject);
var
i, cont:Integer;
p:TPanel;
edt:TEdit;
begin
cont := StrToInt(Edit1.Text);
for i := 0 to (cont-1) do begin
p := TPanel.Create(Self);
p.Left := (20 * i);
p.Top := 0;
p.Width:= 20;
p.Height := 20;
p.ParentWindow := Self.Handle;
p.Name := 'panel' + IntToStr(i);
edt := TEdit.Create(Self);
edt.Left := 5;
edt.Top := 5;
edt.Width:= 10;
edt.ParentWindow := p.Handle;
edt.Name := 'pEdit' + IntToStr(i);
end;
end;
Necesitas un Edit (Edit1) que te indica cuantos debes crear.
Un consejo: Si los "BLOQUES" que debes crear son complejos, tal vez te interese crear un Frame en diseño, añadirle todo lo que necesitas y luego en ejecución crear elementos del tipo de ese Frame.