In that case it might be better to let the TPanel or TGroupBox own the
controls
you put on them.

[CODE]
Procedure TForm1.CreateLabelOnPanel;
Begin
  Panel1 := TPanel.Create(Self);
  Panel1.Left := 8;
  Panel1.Top := 8;
  Panel1.Parent := Self;

  Button1 := TButton.Create(Panel1);
  Button1.Left := 8;
  Button1.Top := 8;
  Button1.Caption := 'TestLabel';
  Button1.Parent := Panel1;
End;

Procedure TForm1.DeletePanelClick(Sender : TObject);
Begin
  Panel1.Free; // This will free BOTH Panel1 as Button1.
End;
[/CODE]

Greetz,

Peter.

  -----Oorspronkelijk bericht-----
  Van: [email protected] [mailto:[email protected]]namens
totallyfreeenergy
  Verzonden: zaterdag 31 oktober 2009 2:45
  Aan: [email protected]
  Onderwerp: [delphi-en] Re: How to create VCL components dynamically


    Thanks-a-lot. I did forget about that :P Now it is all working very
well. I am surprised that the groupbox or Panel don't have a function to
clear all items we put on them. Something like items.free. I had to free the
panel and then re-create the panel again to throw out the components i put
on them.

  Regards
  TFE
  http://totallyfreeenergy.zxq.net

  --- In [email protected], "Peter Luijer" <p.lui...@...> wrote:
  >
  > Make sure you set the Left- and Top-properties of the control in
question
  > correctly
  > relative to the TPanel or TGroupBox, NOT to the form these "Parents" are
on.
  >
  > Greetz,
  >
  > Peter.
  >
  > -----Oorspronkelijk bericht-----
  > Van: [email protected] [mailto:[email protected]]namens
  > totallyfreeenergy
  > Verzonden: zaterdag 31 oktober 2009 0:41
  > Aan: [email protected]
  > Onderwerp: [delphi-en] Re: How to create VCL components dynamically
  >
  >
  > One more question about dynamic instantiation of VCL components....
  > When I try to instantiate on a groupbox or Panel and set the Parent to
  > groupbox1 or Panel1 it is not working. Compiles and executes without any
  > errors. However on objects instantiated.
  >
  > TFE
  > http://totallyfreeenergy.zxq.net
  >
  >
  >
  >
  >
  >
  > [Non-text portions of this message have been removed]
  >



  


[Non-text portions of this message have been removed]

Reply via email to