Jump to content

Components created at runtime are out of order


Fernando Silva

Recommended Posts

I have a simple case of creating panels at runtime. The creation of the components works perfectly, the problem is in the ordering in which the unigui leaves them.

Code:
procedure TMainForm.UniButton1Click(Sender: TObject);
var
PnP: TUniPanel;
I: integer;
begin
  for I := 0 to 10 do begin
    PnP                := TUniPanel.Create(self);
    PnP.Name           := 'PnProg_' + I.ToString;
    PnP.Parent         := SBPrincipal;
    PnP.Width          := 232;
    PnP.Caption        := 'Panel_' + I.ToString;
    PnP.CreateOrder    := I;

    PnP.Align          := alRight;
    PnP.Align          := alLeft;
  end;
end;

 

Result:

image.thumb.png.814c4d5a5e8a08b0166a7edb41c4d1a2.png

I've already tried to reorder them after they were created but I wasn't successful.

Has anyone experienced this problem?

PS: I tried the topic below and it didn't work:

 

 

 

Attached the unigui project.
The same code in a desktop application works normally.

PanelsRT_Unigui.rar

Link to comment
Share on other sites

Hello @mikromundo

I don't understand your suggestion, if I comment on the alignment the panels will overlap. If I leave just the left one the problem is the same.

Have you tried the example I shared?

I know it seems like a simple problem, but it's not, I spent a lot of time testing the properties.

A desktop Delphi project with the same code behaves correctly, it's some detail in unigui.

Thanks.

Link to comment
Share on other sites

Put this:

    PnP.Left           := i * PnP.width;
    PnP.Align          := alRight;
    PnP.Align          := alLeft;

 

It will also be very useful for you to study Unigui's own alignment resources (see the demos).

Unfortunately, I do not use them, because I needed to apply responsiveness (far beyond what exists natively) in Unigui and then I created "Radcore Project" to solve this and several other inconveniences.

 

Link to comment
Share on other sites

Hi @mikromundo, it worked using i *PnP.width;

I was intrigued by the solution, thank you very much for the tip, it solved my problem.

Congratulations on the Radcore project, I didn't know it, I was delighted with its practicality. I'll study a little more. Congratulations indeed!!

 

  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...