# 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?
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
0
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.
0
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
0
Senior .Net ConsultantAuthor Commented:
The Top property of the IFieldObject.

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

mlmcc
0
Senior .Net ConsultantAuthor Commented:
Values of Top? Never tried. But useless unless I can get the actual height of the grown field.
0
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
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Senior .Net ConsultantAuthor Commented:
Too bad it is not supported by CR. Thanks for confirming.
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.