Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

2.10 Formatting Strings, Numbers, and Objects

Formatting Strings

The tutorials earlier in the chapter showed you different ways to format a text object. But it didn’t discuss every formatting option available. The Format Editor has many more options for modifying the way string based report objects appear. The different formatting options are available for textbox objects as well as formulas, report fields, and special fields.

The first tab of the Format Editor dialog box is the Common tab (see Figure 2-19).



Figure 2-19. The Common tab of the Format Editor dialog box.

If you look to the right of many of the properties, there is a button next to it. This is the Formula button. It lets you apply custom formatting to the object using formulas. This is discussed in more detail in Chapter 5.

The properties shown on this tab are common to most of the report objects available. These properties are described in Table 2-3.

Table 2-3. Properties of the Common Tab

Property Description
Tool Tip Text Use the formula editor to set a string that is displayed when the mouse hovers above the field.
Read-only Prevent the object from having any additional formatting changes made to it.
Lock Position and Size Prevent the object from being moved or resized.
Suppress Hide the object.
Suppress If Duplicated Hide the object if it had the same value in the prior record.
Suppress Embedded Field Blank Lines Suppress fields with no data so that a blank line doesn’t appear.
Can Grow Allow the field to expand if the object isn’t big enough to hold the data. The field will only expand vertically and result in the height increasing. The width does not expand.
Text Rotation Rotate the text to a specified angle. A value of 0 is the default and the text displays horizontally. A value of 90 rotates it vertically upward. A value of 270 rotates it vertically downward.
CSS Class Name If you use a CSS file to format report objects, enter the CSS class name that should be applied to the object.
Repeat on Horizontal Pages Repeats an object when a cross-tab expands horizontally across multiple pages.
Keep Object Together Do not let the object cross over into another page.
Close Border on Page Break If a field has a border, and the field extends to another page, then this will close the border on the first page.

Formatting Numbers

Numbers are very similar to regular text objects in that they display characters on the report. The difference being that they can only display numeric characters. Thus, while they have similar formatting features (fonts, borders, etc.), they also have unique formatting features (currency, number of significant digits, etc.).

The Line Object

The line object does exactly what you expect. It draws a line. There isn’t a whole lot you can do with it except change the color, the width and its style (single line, dashed line, etc.) It does have one interesting feature that solves a common problem with line objects. There are times when the detail section has a field that can grow down the report and make the section longer than expected. Since a line has a certain length, when the text object grows the line stays the same size. If you want the line to grow and be unbroken across each row, set the property ExtendToBottomOfSection to True. This ensures that no matter how tall the section grows, the end point will extend to the bottom of the section. If it is a horizontal line, this always moves it to the bottom of the section.

The line object can only do horizontal and vertical lines. It can’t display lines at an angle.

The Box Object

Like the line object, the box object isn’t too exciting. You can change its color, width and style. One nice feature about it is that you can change its properties to round the edges. Depending on how you set the properties, you can make it elliptical or even turn it into a circle. The properties that affect this are CornerEllipseHeight and CornerEllipseWidth. Rather than modify these directly, it is much easier to use the Format dialog box. The second tab is the Rounding tab. It has a picture of what the box looks like and below it is a slider. As you move the slider from the left to the right, it increases the curvature of the edges. When the slider is at the far right, the box is a circle. Once you click OK, the dialog box automatically sets the corner ellipse properties for you.

The Picture Object

The picture object is used for displaying the following image file formats: BMP, JPG, TIFF, and PNG. It doesn’t display GIF files. The formatting options are similar to the other controls in that it has the tabs Common and Border with similar functionality. The Picture tab, shown in Figure 2-20, lets you resize, scale and crop the image. If at any point you feel that you resized or scaled it improperly and you want to restore it back to its original size, click the Reset button located in the middle of the dialog box.



Figure 2-20. The Picture tab of the Picture object’s dialog box.