title: How to dynamically create controls aligned to the top but after other aligned controls?
body: <p>In this particular case I'm using <a href="http://www.est.hi-ho.ne.jp/takeshi_kanno/powerpdf/" rel="noreferrer">PowerPDF</a> library to dynamically build a PDF document, but the same applies for the general concept of dynamically aligning controls sequentially inside of a parent control. In this library, <code>TPRPage</code> is the base control to contain all element controls, in this case, sequential instances of <code>TPRLayoutPanel</code>.</p>
  
  <p>What I do when dynamically adding controls:</p>
  
  <ol>
  <li>Create a control (<code>TPRLayoutPanel</code>)</li>
  <li>Set the control's parent (<code>TPRPage</code>)</li>
  <li>Align the control to top (<code>PRLayoutPanel.Align:= alTop;</code>)</li>
  </ol>
  
  <p>The problem is it gets forced to the very beginning (top) instead of the very end (bottom) of the page.</p>
  
  <p>I've tried setting its order <code>PRLayoutPanel.SendToBack;</code> or <code>PRLayoutPanel.BringToFront</code> but with no luck.</p>
  
  <p>How can I dynamically create and align multiple controls within a parent control sequentially? My only current work-around is to add the controls in reverse order (from end to beginning) which is ridiculously unnecessary.</p>
  
  <p>Here's my universal function which creates every new instance of an aligned control in this parent:</p>
  
  <pre><code>function TfrmReport.InsertPanel: TPRLayoutPanel;
  begin
    Result:= TPRLayoutPanel.Create(PRPage);
    Result.Parent:= PRPage;
    Result.Align:= alTop;
    Result.Height:= 40; //Default, may change later
  end;
  </code></pre>