Add TAdvPanel dynamic to TAdvPanelGroup

Hi,

how can I add a TAdvPanel dynamic to TAdvPanelGroup so that the Panel is added at the bottom? The main process of adding dynamic is clear.

Best regards ...

Please call AdvPanel.AppendPanel;

Hi,

where can I call Append here?:

procedure Tarticle.createPanel(inCaption : string; inId : integer);
var
  ap: TAdvPanel;
begin
  ap := TAdvPanel.Create(AdvPanelGroup1);
  ap.Parent := AdvPanelGroup1;
  ap.Assign(AdvPanel1);
  ap.Caption.Text := '<IND x="10"><FONT color="#FFFFFF"><B>' + inCaption + '</B></FONT>';
  ap.Caption.Color := $00C4CCD0;
  ap.Caption.ColorTo := $00C4CCD0;
  ap.Caption.Visible := true;
  ap.Tag := inId;
  ap.collaps := true;
  ap.FullHeight := 120;
  ap.collaps := false;
end;

Best regards ...

Hello,
here's an example (if still needed):


  with AdvPanelGroup1.AppendPanel do begin
    Text := 'Created at '+TimeToStr(Now);
    Caption.Text := 'Runtime created panel';
    Collaps := true;
    FullHeight := 32;
    Collaps := false;
  end;


Regards,
Tobias

Hi,

thanks Tobias, that worx! One question left: How to add components to the new panel (how can I ask the owner?)?

Best regards ..

Hello Heinz,

if you want to access the newly added panel it is the easiest way to use something like

MyPanelGroup.Panels[MyPanelGroup.PanelCount-1]

right after the AppendPanel.
I'd even go so far to have an extra variable to have it assigned exactly that last added panel, which then is surely simpler and more readable in code:

var FCurrentPanel : TAdvPanel;
begin
  ... // some code to add panel somehow needs to be before this
  FCurrentPanel := MyPanelGroup.Panels[MyPanelGroup.PanelCount-1];
  with TEdit.Create(FCurrentPanel) do
    Parent := FCurrentPanel;
    Left := 8;
    Width := 100;
  end;
  ...
  // ... any further components to be added...


Regards/Grüsse,
Tobias

Hi,

Delphi throws an Exception: E2010 Inkompatible Typen: 'TAdvPanel' und 'TCustomAdvPanel'. If I use FCurrentPanel : TCustomAdvPanel as var I got an Stack Overflow. What should I do?

Best regards ...

TCustomAdvPanel should be used.
For what statement exactly do you see the stack overflow as I can't reproduce a problem here.

Hi,

I call this procedure from a loop:

procedure Tarticle.createPanel(inCaption : string; inId : integer);
var
  ted : TEdit;
  cp  : TCustomAdvPanel;
begin
  with AdvPanelGroup1.AppendPanel do
  begin
    Caption.MaxGlyph.LoadFromFile(path + 'close.bmp');
    Caption.MinGlyph.LoadFromFile(path + 'open.bmp');
    Caption.MinMaxButton := true;
    Caption.Text := '<IND x="10"><FONT color="#FFFFFF"><B>' + inCaption + '</B></FONT>';
    Caption.Color := $00C4CCD0;
    Caption.ColorTo := $00C4CCD0;
    Caption.Visible := true;
    BevelInner := bvNone;
    BevelOuter := bvNone;
    BorderStyle := bsNone;
    Tag := inId;
    collaps := true;
    FullHeight := 120;
    Name := 'Panel' + IntToStr(inId);
    collaps := false;
  end;
   cp := AdvPanelGroup1.Panels[AdvPanelGroup1.PanelCount-1];
   ted := TEdit.Create(cp);
   parent :=  cp;                              //If I use this I get an Stack Overflow
end;

Best regards ...

You missed something...

parent := cp;


has to be

 ted.parent := cp;

Oh yes, now I see ;-). But I've the problem, that the edit is only displayed on the first panel (which is not build dynamic)?

Best regards and many thanks

The panel on which the edit is displayed is determined by 

so, make sure that cp is effectively the panel where you want to have the edit control appear.

Hi,



how did I get the last AppendPanel. It seems that


not works because I get only the first (not dynamic) build panel.

Best regards ...

The panel you added is returned by the function AppendPanel

That's it. Thanks and best regards!