Link to home
Start Free TrialLog in
Avatar of Éric Moreau
Éric MoreauFlag for Canada

asked on

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
Avatar of Mike McCracken
Mike McCracken

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}

Open in new window



mlmcc
Avatar of Éric Moreau

ASKER

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.
I am not aware of any way to find the actual height.

What TOP property are you referring to?

What version of Crystal?

mlmcc
The Top property of the IFieldObject.

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

mlmcc
Values of Top? Never tried. But useless unless I can get the actual height of the grown field.
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Too bad it is not supported by CR. Thanks for confirming.