Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

2.14 Moving Object with Guidelines

Moving objects with Guidelines

The previous section discussed how to add objects so that they lined up with existing objects. But it didn’t cover how to move multiple objects so that they stay lined up. This is where Guidelines are used.

Guidelines create an anchor for attaching multiple objects. The benefit is that anytime you move the guideline, all the objects attached to it move also. If you have a multi-column report with many columns and you have to insert a new column, it can be difficult to move all objects over to make room for the new column. But if you anchor all the objects in a column to a guideline, you can move the guideline and all the objects move with it. You can move entire rows and columns of fields, trouble-free, without losing alignment.

Guidelines are inserted into a report by clicking on either of the rulers. A small red colored marker appears (similar to the letter T turned on its side), to represent where the guideline is. You can see in Figure 2-23 that there is an example of a guideline on each ruler. If you added guidelines to your report and they aren’t visible, select the menu option File > Options > Layout Tab to check that the Guidelines option is enabled.



Figure 2-23. Guidelines on the ruler.

Once a guideline has been added, you can attach objects to it. Drag an object so that one of the edges lines up with the guideline. This automatically attaches the object. Objects can also be attached at the center points. A small red marker appears in the corners of the object along the edge that is attached. This makes it easy to see which objects are attached to which guidelines. Do this for all the objects in a row or column that need to stay aligned while being moved around.

Text objects behave a little differently than other report objects. Most report objects attach along the border of the object. But a single-line text object attaches to the guideline along the base of the text, not the bottom edge of the object. This guarantees that all the text on a line lines up correctly even when the fonts are different. A multi-line text object can either use the bottom edge of the object or the base of the text of the first line.

Question: At the bottom of a page I have multi-line text objects that can grow. I want to align them so that the bottom of each text object is aligned each other. Right now when they grow they move down the page and the bottoms are at different places. How do I align the bottoms?

Answer: You are effectively trying to change the Can Grow option so that it “grows upward” on the page instead of growing down the length of the page. This is not possible.

Be careful when moving guidelines to make sure that your mouse stays within the ruler’s region. Personally, I have a very bad habit of accidentally moving my mouse out of the ruler region and this makes the guideline disappear. Hence, if you deliberately want to remove a guideline then click on it and drag it off the ruler. If you did this by mistake, press Ctrl-Z to undo the action and the guideline appears back on the ruler.

One thing to be aware of is that even though you can move a guideline and it takes the objects with it, it doesn’t work the other way around. You can’t move an object that is attached to a guideline and expect the guideline to move with the object. Instead, the object becomes unattached from the guideline and moves around independently. It is no longer anchored to the guideline.