0

Is there a way that I can prevent re-arrangement of my visual controls during runtime with dynamic RESIZING of some of the controls like TLayout/TVertScrollBox in my case?

Here's the controls contained in my form:

Form
   TabControl
      TabItem1                  // select and filter a meta to be to shown in TabItem2
          TVertScrollBox1
      TabItem2                  // select and filter an item to be shown in TabItem3
          TVertScrollBox2
      TabItem3                  // provide the details of the selecte item from TabItem2
         TVertScrollBox3
            TLayout1
               TImage
               TLabel1
               TLabel2
               TLayout2         // get its height from TListView item(record) count
                  TLabel3
                  TListView     // dynamically based on item(record) count provide the height TLayout2

Based on the above setup, the size of TLayout1 is dependent on the record count (fdquery.recordcount) to be shown in TListView.

Upon running the program, the controls changed its position like the TLabel2 will move to the bottom and all others arbitrarily.

I was given the answers here and another one here but it discussed about TPanel created at runtime. I am not really sure if these are relevant to my questions. Because I don't use TPanel controls and its being created at runtime. Mine is create at design time except that some controls are dynamically resizing at runtime.

I found another solution from youtube of Alister Christie to create a procedure below:

procedure TformMain.OrderControls;
begin
   TImage.Align.alBottom := 0;      //Alister sample is Button1.Left := 0;
   TLabel1.Align.alBottom := 0;
   TLabel2.Align.alBottom := 0;
   TLayout2.Align.alBottom := 0;
   TLabel3.Align.alBottom := 0;
   TListView.Align.alBottom := 0;
end;

procedure TfromMain.TVertScrollBox1ItemClick(const Sender: TObject; const AItem: TListViewItem);
begin
    OrderControls;
end;

But, I am getting the error on alBottom as it is already deprecated. I tried Align.Bottom and this time it is not recognized.

My issue is getting deeper here.

Going back, all I want is how to make my controls fix to its assigned location even if my other controls are dynamically resizing at runtime.

Juke
  • 135
  • 2
  • 9
  • Painting time is not an issue here. Are you changing visual or size properties at the runtime? If so, you will need to manually recalculate positions like it is explained in duplicate questions. – Dalija Prasnikar Jun 21 '20 at 08:23
  • @DalijaPrasnikar Yes, the size of TLayout is changing during runtime. Forgot to mention. But I'll look into the duplicate questions. I'll get back to you. – Juke Jun 21 '20 at 11:07
  • If the duplicate does not solve your problem, please edit this question and add [mcve] – Dalija Prasnikar Jun 21 '20 at 11:17
  • @DalijaPrasnikar Sure I will. Thanks. – Juke Jun 21 '20 at 11:17
  • @DalijaPrasnikar I checked and tried the answers here but it looks like it is different from my case. I have updated my questions above. Please check and open the case if you agree with me? thanks. – Juke Jun 22 '20 at 00:58
  • Note that the Alister Christie video talks about VCL components, you are using FMX. `TLabel1.Align.alBottom := 0;` is a mess. Either `Label1.Align := TAlignLayout.Bottom;` (which you probably do not want to use) or `Label1.Position.Y := 0;` The latter being comparable with mentioned video. – Tom Brunberg Jun 23 '20 at 08:39

0 Answers0