Tuesday, January 8, 2013

Using grids and guidelines in Crystal Reports

Each section of a report contains a design grid. The grid always exists; however, Crystal Reports allows you to determine if the grid is visible or not and allows you to establish a grid size (how far each increment is apart).

1. On the File menu, select Options.

2. The Grid Options is located under the Layout tab.

The check boxes allow you to show the grid in Design and/or Preview mode. You can also set the grid size.

For example, setting the grid size to .167 will give you six grid lines per inch. The grid size is the same for all sections. The grid is measured from the upper left-hand corner of each section and continues down, and to the right, until the end of the section. A new grid of the same size then begins from the upper left-hand corner of the next section. This continues throughout the entire report.

The Options dialog box also gives you the option of selecting or clearing Snap to Grid. When you select Snap to Grid, the upper left corner of all newly placed text-based and OLE objects’ boundaries will snap to each grid point. Objects placed before selecting Snap to Grid will not move to snap to the nearest grid point. They will remain where they are. If you resize an object, the side(s) that you are resizing snap to the closest grid point. If you have several text objects of different font sizes snapped to the same vertical grid point, the base of the text will not line up because it is the object’s upper left corner that snaps to the grid. The height of the text object and the distance from the top border to the text’s baseline is determined by the size of the font.

In the example below, Free Form Placement and Snap to Grid are both selected.


This field is placed on the report and then the font size is increased. Notice that the upper left boundary (indicated by the corner crop marking) is snaps to the grid point while the other three corners are not. The text-based object increases in size to accommodate the new font size.


This field is placed on the report and then the right border is moved. Notice that both the left and right boundaries are now snapped to a grid point.


This field is inserted and then the bottom boundary is dragged down. Notice that the bottom boundary also snaps to the grid line but the font size does not change.


This field is simply placed on the report. The boundary’s upper left corner snaps to a grid point.


This field is placed on the report when Snap to Grid is not selected. Notice that the object does not move and its boundaries do not snap to any grid point.

Notice that while the CUSTNUM, CONAME and STATE fields are snapped to the same horizontal grid line, the bases of the three fonts do not line up.

Also notice the grid in the top section with the five fields. The section consists of three full grid lines and a partial fourth. Even though the fourth grid line is not visible, the section below starts with a new grid with the sections upper left corner as (0,0).

Guidelines are used to help you line up objects. They have a snap property that automatically snaps objects to them. That is, objects will connect to the guidelines as positioning devices. An OLE object can snap to a horizontal guideline on its top, bottom, or horizontal midline (the invisible line that bisects the object horizontally). However, the snap property of guidelines is different for text-based objects. When a text-based object snaps to a guideline, it is the baseline of the text and not the boundary of the object that snaps to the guideline. You can see a red tick in the left and right object border where the baseline is. Thus, if you need to place several text objects of different font sizes on one line and have their baselines line up, you will want to snap them to a guideline.

If you have selected Snap to Grid and you want to position text objects of different font sizes so that their baselines line up:

1. First insert a guideline. The guideline will snap to the grid line when it is placed.

2. Snap the text-based objects to the guideline.


When placing text-based objects, snapping to a guideline takes precedence over snapping to a grid line. However, if you later resize the text object’s height, the text object will snap the boundary being resized to the closest grid line.

In the example above, when CONTACTLN is first inserted, its baseline snaps to the guideline. When the upper border is then resized by dragging the object’s upper border upwards, the object assumes the characteristics of Snap to Grid. When PHONE is first inserted, its baseline also snaps to the guideline. However, when it is resized by dragging the bottom boundary downward, the object expands but the precedence of the text snapping to the guideline, instead of the grid line, is maintained.

Becoming familiar with the properties and functionality of grid lines and guidelines and working with the two requires some experimentation. It is important to note that selecting/clearing Snap to Grid and/or using guidelines or not, is a matter of selecting the best methodology for positioning the objects in your report exactly where you want them to be. Also remember that if you have Free Form Placement cleared (binding the section to lines) and you select Snap to Grid, all objects will snap to the guidelines for vertical placement and the left boundary will snap to both vertical guidelines and grid points.

No comments:
Write comments
Recommended Posts × +