GridPanel does not adjust on first resize

I have a problem that I cannot solve, although I spend a lot of time on it.

I usually use GridPanels to align form controls. This, however, causes an annoying error. When the alignment mode of the GridPanel is alClient and I maximize its parent window, the GridPanel adjusts to the new size of this window, however, the controls located on the grid do not work. They remain in the same position as before resizing the window. This only happens when maximizing the first window. If the window is first manually resized, everything is in order. I think the grid adjusts its child controls after the second resize event (??).

What if the GridPanel is working correctly if it comes to this error? This may be enough to send him a message (but what message?), I do not know. I tried using Implement, Update, etc., but they did not help.

Thanks for your help in advance,

Mariusz.

+6
alignment resize controls delphi tgridpanel
source share
5 answers

Ah, I had similar problems. This may be due to the resizing problem in VCL. You might want to try Andreas Hausadenen's fix . This seems to work for me in most cases.

+7
source share

I found one trick.

In the OnResize event of the OnResize parent, change the grid width by 1 pixel.

then the gridPanel will notice the resized, and then rebuild the sub-controls in the gridpanel.

below.

 procedure TForm1.FormResize(Sender: TObject); begin GridPanel1.Width := GridPanel1.Width - 1; // subtract 1 GridPanel1.Width := GridPanel1.Width + 1; // recover width by adding 1 end; 
+2
source share

Changing the width / nullity of the control does not work for me (has something changed in recent versions of RAD Studio?).

In any case, a similar, simple workaround along this line:

 procedure TForm1.FormResize(Sender: TObject); begin GridPanel1.ControlCollection.BeginUpdate; GridPanel1.ControlCollection.EndUpdate; end; 
+2
source share

I also had this error on several projects. I'm not sure how I solved it (this was in projects for my previous employer, I no longer have access to this source code). I think I had to redraw / update the parent frame or form on which the GridPanel was placed.

+1
source share

when resizing the owner of the call to GridPanel.Invalidate. I did not check. I hope this works.

0
source share

All Articles