Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I prevent two align to bottom controls from reversing order?

I have a form with three main components:

  1. A FlowPanel that is set to Align to Client
  2. A second FlowPanel set to Align to Bottom
  3. A StatusBar set to Align to Bottom.

Everything starts out looking great. But the FlowPanel that is aligned to the bottom is also set to AutoSize. It contains a panel that can collapse itself. The internal panel contains summary information that the user can decide to hide. This drops the size of the FlowPanel to a very small size but not completely gone. There is still a button where the user can re-expand the summary panel.

The problem comes when the panel is re-expanded causing the FlowPanel to grow. At that time the order of the Status Bar and the FlowPanel is reversed. They are both still set to align bottom but now the status bar is above my FlowPanel.

I can duplicate this in a test app without the Collapsing panel just by putting button on the form to see the bottom flow panel's height. If the height is increased the order changes. If it is decreased then everything stays in the same order. The only code in my test form is:

FlowPanel2.Height := FlowPanel2.Height * 2;

I also tested this with the bottom panel being a regular TPanel instead of a FlowPanel with the same results.

Any ideas on why this is happening and how to prevent it?

Moving Status bar image

like image 221
Mark Elder Avatar asked Dec 20 '12 20:12

Mark Elder


2 Answers

My Solution:

  1. Place a Statusbar on form and align to Bottom
  2. Place a Panel (Container_Panel) on form and align to Client
  3. Place a FlowPanel on Container_Panel and align to Bottom
  4. Place a FlowPanel on Container_Panel and align to Client

Now you should have no problems with that anymore

like image 132
Sir Rufo Avatar answered Oct 17 '22 02:10

Sir Rufo


I sometimes have this too. My solution is to set Top of the control that shall be at the bottom to a "big enough" value - something like OtherControl.Top + OtherControl.Height + 1 should work or even MaxInt IIRC.

like image 33
Uli Gerhardt Avatar answered Oct 17 '22 02:10

Uli Gerhardt