Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

2.13 Moving and Sizing Report Objects

Moving and Sizing Report Objects

Even though we all wish our reports were perfect the first time through, this is rarely the case. After adding objects to the designer, you frequently need to reposition objects and change their size. An earlier section of this chapter showed you how to add report objects to the designer. This section shows you how to manage objects within the report designer.

If you have an existing control that you want to reuse so that you don’t have to redo its formatting, you can click on it and copy and paste it. This creates a copy that is attached to your pointer and will move around as you move your mouse. When you have it positioned properly, click the mouse button to drop it there. You can also select multiple objects for copy and paste.

Selecting multiple objects is done by holding down the control or shift key and clicking on the individual controls. You can also draw a temporary window on the report and any controls that are included in the window get selected. Do this by holding down the mouse button and moving the mouse to enlarge the box. Let go of the mouse when the box is large enough and any object that is fully or partially within the box gets selected.

There is a strange behavior to be aware of when selecting multiple objects using the window technique. You can’t draw a window if another object is already selected. You have to first click on an empty portion of the report designer to unselect the current object and then you can draw the box. For example, assume that you selected a text object and then you decided that you really wanted to select multiple text objects instead. After clicking the first text object, you click elsewhere on the report and attempt to draw a window. Unfortunately, nothing happens. It only results in the textbox getting unselected. You need to click the mouse a second time to start drawing the window.

Certain objects can be more difficult to select than others. For example, some reports have so many objects in a section that the objects overlap or they are not currently visible in the designer. Other objects like the line object are simply hard to click on because they are so small. You can select all the objects in a section by right-clicking in gray area to the left of the section and choosing Select All Objects. This highlights every object in the section, including the ones you can barely see. This also makes it easy to move all the objects from one section to another section. A second way of highlighting a small object is to click on it in the Report Explorer window. This automatically selects it in the Design tab. You can also hold down the shift key in the Report Explorer window to select multiple objects.

Resizing a control is done by first clicking on it to highlight it. This creates little dark squares in the corners of the object and in the middle sections. These are sizing handles that can be clicked on and dragged around. Position the mouse over one of the sizing handles and click the mouse button to drag the handle to the new position. Let go of the mouse button to release the handles when you are finished.

When resizing multiple objects, the sizing handles only appear on the last object selected. As you resize the last control, its new size dynamically changes as you move your mouse. The other controls will not change until you release the mouse button. At that point they all “snap” into their new shape.

There are times when you have a lot of different sized objects on the report and you need them all to be the same size. This often happens after using the report wizard to create the first draft of a report and it puts the objects on the report for you. You have to go back and adjust their position and size to make the report look they way you want it to. You can have Crystal Reports adjust the size and position of all the objects to be consistent with each other. Do this by selecting all the objects and then right-clicking on the main one and select the Size menu option. From there you can choose Same Width, Same Height, or Same Size. The objects will be resized to match the object that you right-clicked on.

When moving objects around the report, it can be helpful to display the grid lines. This makes it easier to line up objects with each other. Turning the grid lines feature on or off is controlled by changing the designer properties. Right click on the report and select Designer > Default Settings.

An alternative for doing precise adjustments to an object is to use the keyboard instead of the mouse. Due to the design of a mouse ball, it can sometimes be hard to move the mouse a very small distance without it jumping around a bit. Instead of using the mouse, use the keyboard to change an object. By pressing down the Control key and hitting the arrow buttons, the object moves in the direction of the arrow. Pressing down the Shift key and hitting the arrow buttons adjusts the right side and bottom edge of the object. You can make the object larger or smaller in all directions.

When placing objects that should all line up either horizontally or vertically, it can be difficult to make sure they all line up along the exact same axis. Crystal Reports allows very precise placement of objects and this means that objects can easily be one or two pixels off. You have to tweak them with your mouse to make sure they line up exactly. The Snap To Grid option makes this much easier because it makes sure that as long as you come close to lining one object next to the other, they will both land on the same grid marker.

If you are working on a report with multiple sections, lining up columns can be trickier even with the help of the grid points. It gets harder to judge the exact location and width of different objects if they are in different sections of the page. Crystal Reports gives you a few different ways to help make sure that the appropriate objects are lined up correctly. They are the alignment markers and the functions on the alignment menu.

Alignment markers are temporary transparent lines that extend both horizontally and vertically from the edges of the object to the page perimeter. They make it easy to see which objects have the same alignment. They only appear when you click on the object and hold down the mouse. Once you release the mouse, the lines disappear. You can even move the object around and the lines stay visible until you release the mouse. This is probably best understood with a picture. See Figure 2-22.



Figure 2-22. Alignment markers make it easy to align objects.

The object in Figure 2-22 has the border emphasized and each border has thinner lines extending past it in every direction. This makes it easy to see exactly where the object is along the ruler markers, but you can also see which objects have the same alignment. It becomes easy to add an object to the Page Header section and position it so that it is in exact alignment with an object in the Page Footer.

Even though the alignment markers are helpful when adding new objects to the report, they are only really useful for working with single objects. Sometimes you have a report with multiple objects along the same column and you need a quick way to get them all aligned. The Alignment menu options give you many options for multiple aligning objects. You can select multiple objects and set them to all line up along their right edge, their left edge, the top border and many other ways.

To align multiple objects, select the group of objects that need to be aligned. Once the objects are selected, right-click above one of the objects and select the menu option Align. This presents a sub-menu of the different ways to align the objects. There are eight ways in total and each is self-explanatory.


A key part to remember is that the “anchor” object is the object that the mouse was hovering over when you did the right-click. What this means is that when you tell the program to align all the objects along the Top for example, the program needs to know which object should be used to define where the top is. The “anchor” object is the object that you right-clicked on after they were all selected. If you make the mistake of right-clicking on an area of the report where there isn’t an object, the grouping is reset and you have to start all over again. So be careful where you right-click!