Page 1 of 1

How To Center Vertically

Posted: Wed Jul 05, 2006 11:57 pm
by DickBryant
The application which I am upgrading with TRichView had the ability to center text both horizontally and vertically.

I achieved the vertical centering by loading the text into an invisible TMemo and using TMemo's Lines.Count property to count the lines. I then calculated the number of lines possible in the resizeable window and inserted 1/2 this number of blank lines in front of the text before displaying it in the actual TMemo.

I tried using the obsolete TRV.Lines property, but it doesn't seem to actually return the number of lines - more like the number of items?

Do you have any suggestion on how to achieve vertical centering for a TRichViewEdit (read only)?

Thanks!

Posted: Thu Jul 06, 2006 11:25 am
by Sergey Tkachenko
Set RichView.VAlign = tlCenter.

TRichView is not TMemo, lines can be of different height.

Posted: Thu Jul 06, 2006 2:05 pm
by DickBryant
That was easy!

Perhaps cross reference the .VAlign property (of TRichView, TRichViewEdit) with the .Style.ParaStyles[0].Alignment property to make it easier to see the relationship between the global vertical centering and the by-paragraph horizontal centering.

It's clear to me NOW why it's that way, but after finding the horizontal centering I didn't think to look at the global level for the vertical control.

Thanks!