Creating and Controlling Groups

3 4

You should create a group when you want several shapes to move and size together, yet retain their individual formatting attributes or multiple text blocks. When you group items, a new ShapeSheet spreadsheet is created for the group, each member of the group maintains its own ShapeSheet spreadsheet, and the group becomes the parent coordinate system for each original item. Additionally, formulas for shapes included in the group, such as 1-D Endpoint or Shape Transform values, are modified to refer to the group rather than the page.

figure 6-1. groups can contain shapes with different formatting attributes.

Figure 6-1 Groups can contain shapes with different formatting attributes.

Grouping and Ungrouping Shapes

It's a good idea to group shapes before adding connection points or defining custom formulas because these elements generally must reference the group to work properly.

  • To create a group, select shapes for the group. On the Shape menu, point to Grouping, and then click Group to combine the selected shapes or other groups into a new Microsoft Visio shape with components that can still be edited and formatted individually.
  • To ungroup a group, select the group. On the Shape menu, point to Grouping, and then click Ungroup.

Modifying a Group

Users can add shapes to a group or remove shapes from a group. Depending on the solution you're developing, the ability to modify a group might be desirable, or it might cause your shapes to work in unexpected or undesirable ways. You can prevent a group from being modified by setting the LockGroup cell in the Protection section of the group's ShapeSheet spreadsheet to true .

You or your solution users can automatically add shapes to unlocked groups in the following two ways:

  • Drag a shape that is designated to be added to a group on drop, and drop it onto a group that is designated to accept dropped shapes.
  • To designate a group to accept dropped shapes, select Accept dropped shapes under Group behavior in the Behavior dialog box (with the group selected, click Behavior on the Format menu). Or enter TRUE in the IsDropTarget cell in the Group Properties section of the group's ShapeSheet spreadsheet.

    To designate a shape to be added to a group on drop, select Add shape to groups on drop under Miscellaneous in the Behavior dialog box. Or enter TRUE in the IsDropSource cell in the Miscellaneous section of the shape's ShapeSheet spreadsheet.

  • Select both the group and shape(s) to be added to the group. On the Shape menu, point to Grouping, and then click Add to Group.

You or your solution users can remove a shape from a group in one of two ways:

  • Subselect a shape in a group. On the Shape menu, point to Grouping, and then click Remove from Group. The shape remains, but it is no longer a member of the group.
  • Subselect a shape in a group, and then press DELETE.

How Grouping Shapes Affects Their Formulas

When you add a shape to a group, its parent coordinate system switches from the page's coordinates to those of the group. When you ungroup shapes or remove the last shape from a group, the group is no longer the parent, and the group ShapeSheet spreadsheet is deleted. Formulas that refer to parent coordinates change when you group or ungroup the shape, and custom formulas that you define for a shape can be overwritten.

The following table shows the cells that are reset with new formulas when you group or ungroup shapes.

How formulas change when a shape is grouped or ungrouped

Section

Cell

What happens

Shape Transform

Width, Height

After grouping, formulas reference the group to define the shape's size in proportion to the group's size. After ungrouping, formulas reference the width and height of the new parent or are constant if the new parent is a page. Formulas protected with the guard function are not affected.

Shape Transform

PinX, PinY

Formulas base the pin coordinates on the group's or new parent's coordinate system. After grouping, formulas define the pin's location in proportion to the group width and height.

1-D Endpoints

BeginX, BeginY, EndX, EndY

Formulas base the coordinates of the begin and end points on the parent's coordinate system. After grouping, formulas define the endpoints' position in proportion to the group width and height.

Alignment

[all cells]

After grouping, formulas base the position of the alignment guide on the group's or new parent's coordinates.

When you group shapes that are connected to other shapes, the connections are maintained, unless a shape is connected to a guide that has—or as a result of the grouping will have—a different parent. If a shape is glued to a guide and you add the shape but not the guide to a group, the shape's connection to the guide is broken. The reverse is also true: If you add a guide to a group, but don't also add shapes that are glued to that guide, the shapes' connections to that guide are broken. If you include both the guide and the shapes that are glued to it, the Visio engine maintains the connections.



Developing Microsoft Visio Solutions 2001
Developing Microsoft Visio Solutions (Pro-Documentation)
ISBN: 0735613532
EAN: 2147483647
Year: 2004
Pages: 180

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net