# Crystal Reports : Centering a field on a row that has a cell with CanGrow set to True

I have a field on a report that has its CanGrow property set to True.

On rows were the content spans on 2 or 3 lines, I would like the other fields of the same row to be centered on the row.

How can I do that?
ee-cr.png
LVL 71
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Do you mean centered vertically?
Crystal can't do it directly.

I have done that through formulas.

Basic idea
Determine the number of lines the can grow field will take
If there are <CR><LF> in the text you can count them.  If not then divide the length of the field by the number of characters that fit in the box (may have to play with the number to get the right number)
Font size 10 is 12 characters per inch  size 12 is 10 characters per inch
To vertically center
add a chr(13)  <CR> for every 2 lines in the field.

``````WhilePrintingRecords;
Local NumberVar numLines;
Local NuberVar Index;
Local StringVar strOut;

numLines := Length({YourField}) / 25;
numLines := numLines \ 2;

strOut := '';
For Index := 1 to numLines do
strOut := strOut & chr(13);

strOut  & {FIeldToCenter}
``````

mlmcc
Senior .Net ConsultantAuthor Commented:
yes vertically.

Your idea would work for odd number of lines but not for even number of lines!

And instead of hard coding 25 as the number of characters per line, is there a way to find the actual height of a grown field? Maybe I could play with the Top properties of other fields then.
Commented:
I am not aware of any way to find the actual height.

What TOP property are you referring to?

What version of Crystal?

mlmcc
Senior .Net ConsultantAuthor Commented:
The Top property of the IFieldObject.

I am using CR 13 (for Visual Studio 2013).
Commented:
I don't use .Net or that version.  Can you change values for each record?

mlmcc
Senior .Net ConsultantAuthor Commented:
Values of Top? Never tried. But useless unless I can get the actual height of the grown field.
Commented:
I have heard of tools that can determine exactly using the printer driver how many rows it will take which you could then multiply by the row height to get the exact height of the box.  I don't recall ever finding one that would work with Crystal.

Beyond my programming knowledge.

So many other tools have that capability, not sure why Crystal didn't do it.

mlmcc

Experts Exchange Solution brought to you by