Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Align Center not centering



Permlink Replies: 1 - Last Post: Nov 19, 2016 7:49 PM Last Post By: Dave Nottage
Frank Yingst

Posts: 175
Registered: 1/19/05
Align Center not centering
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 19, 2016 6:47 PM
The reason that it won't center correctly is because there are controls to the left and right of it that are different sizes. How can I get it to ignore those other controls and just center it in the TPanel ?

I guess I could do a calculation in code to center it when the form loads or is resized. Is that the best way?

update: I solved the problem by lining up 3 equal sized TPanels on top of the 1st TPanel and then putting the controls on each of those.

Edited by: Frank Yingst on Nov 19, 2016 7:48 PM
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Align Center not centering [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 19, 2016 7:14 PM   in response to: Frank Yingst in response to: Frank Yingst
Frank Yingst wrote:

The reason that it won't center correctly is because there are controls to the left and right of it that are
different sizes. How can I get it to ignore those other controls and just center it in the TPanel ?

This is something that annoys me, too. Easiest workaround is to have a TLayout inside the TPanel that has Align as
Contents, and parent the control you want centred to that.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02