9 Replies Latest reply: Oct 21, 2009 2:13 AM by Earl Reyes RSS

Vertical Alignment in Fields

Glenn Frei
Currently Being Moderated

Using Crystal Reports 2008 to design a report:

 

I would like to VERTICALLY align text in a field. (Centred vertically).

 

I know you can format fields and set horizontal alignment, either by selecting from a drop down or using a conditional format.

 

Why is there no option to set vertical alignment?? Doesn't anyone ever need to do this? (Searching through dozens of internet forums, it seems yes, but no conclusive answers to this problem have been offered).

 

What is the alignment constant (mentioned in help section: "Alignment Constants") "crCenteredVertically" for?? How and where is it used?

 

For that matter, why does the Object Size & Position dialogue box offer to place a condition on the X  (horizontal) position but not on the Y (vertical) position. This would have been a good workaround.

 

ANY SUGGESTIONS? Thanks in advance!

 

NB: I have do NOT require the field to grow. But I would like the text to move within the boundaries of the field (using a formula to generate a text string which contains between 5 and 7 lines of text)

  • Re: Vertical Alignment in Fields
    Asha Lund
    Currently Being Moderated

    Hi Glenn

    You can set the alignment as vertical would request you to follow the below steps.

    1)Right click the particular object

    2)Click on "Format Editor"

    3)Click on "Common Tab"

    4)Change the "Text Rotation" to 90 degree.

    5)Click on OK.

    6)In design tab increase the size of that particular object.

     

    I hope this will work.

     

    Regards

    Asha Lund

    • Re: Vertical Alignment in Fields
      Glenn Frei
      Currently Being Moderated

      Thank you for replying but that doesn't answer my question I'm afraid.

       

      I don't want to rotate the text. I want the text to remain 0 degrees, but centred vertically inside the cell.

       

      (Imagine the cell is 3 lines high and is displaying 1 line of text - I want the text to occupy line 2).

       

      I have formulas which generate varying amounts of data, and I want the data always to be centred (vertically) inside the cells.

       

      I can't think why this feature would not be available in Crystal Reports?

       

      Can anyone think of a workaround?

      • Re: Vertical Alignment in Fields
        Currently Being Moderated

        Do you mean the text is cutting off if it exceeds the length of the cell instead of printing in the next line?

         

        If so try using can grow option for that object by right clicking on the object formula go to format field>common>check the check box Can Grow

         

        I hope this is what you mean!

         

        Raghavendra

      • Re: Vertical Alignment in Fields
        Jason Long
        Currently Being Moderated

        Glen,

         

        Here is the only way to "vertically" align text in CR... that I know of anyway...

         

        1) Place a text box where you want the field to go

         

        2) Drag your field into the text box

         

        3) Double click the text box to make it editable

         

        4) Place the cursor in front of the field name

         

        5) hit the Space bar and then the Enter key.

         

        6) Highlight the space and adjust the font size (of the space only) until the field is centered.

         

        Fun huh?

         

        Jason

      • Re: Vertical Alignment in Fields
        Fritz Feltus
        Currently Being Moderated

        You say that your formula returns between 5 and 7 lines of text... are these lines separated by carriage return (new line)?

         

        If so, you could conditionally add more new lines at the beginning of your text depending on how many lines of text you have:

         

        numbervar numOfLines := ubound(split({@formula},chr(10)));
        if numOfLines = 5 then
            chr(10) + chr(10) + {@formula}
        else if numOfLines = 6 then
            chr(10) + {@formula}
        else if numOfLines = 7 then
            {@formula}

         

        Cheers,

        Fritz

        • Re: Vertical Alignment in Fields
          Glenn Frei
          Currently Being Moderated

          Hi Fritz

           

          Thanks, your answer is the closest to a solution I have seen in any forum so far!

           

          Had thought of that. The only shortcoming is that using this method the text will be (exactly) centred for EITHER even number of lines OR odd number of lines (depending on what height I position the field).

           

          There is another solution I am about to try:

           

          Duplicate my field in three different sizes and position at three different heights (on top of each other). By suppressing each field (except one) conditional on the number of lines should help to display the text EXACTLY where I want it.

           

          I'd still like to know what the allignment constant crCenteredVertically (Center vertically) is for. Anyone who can shed light on this, please let me know!

          • Re: Vertical Alignment in Fields
            Fritz Feltus
            Currently Being Moderated

            >>The only shortcoming is that using this method the text will be (exactly) centred for EITHER even number of lines OR odd number of lines (depending on what height I position the field).

             

            You could conditionally change the font sizes within your formula field, this could help you fine tune the amount of space you need at the top of your field... you would have to use something like HTML interpretation, as otherwise you wouldn't be able to set several font sizes within one field.

             

            '<font size="5" face="Verdana">&nbsp</font>' +
            '<br><font size="2" face="Verdana">This is a paragraph.</font>'

             

            Edited by: Fritz Feltus on Aug 7, 2008 9:37 AM

             

            By the way, I don't think the crCenteredVertically alignment constant has been implemented yet. I'll have a look if I can find any more information on that.