Grouping Shapes Overview
This page discusses the following topics:
Ungrouping and Removing Shapes from a Group
Determining if a Shape is Contained by a Group
Returning the Shapes Contained by a Group
A group is a shape itself. It can be added with the mouse with ViewMouseTool
or programmatically with ShapeAdd.
The shape type for a group is 18. When initially added, a group shape will be empty, and will not show
on the control until shapes are added to it.
Adding a group with the mouse is accomplished by setting the ViewMouseTool to 18, then clicking
anywhere on the control view.
There are two methods for adding shapes to a group. To add a single shape, call GroupAddShape.
To add shapes that are currently selected, call GroupAddSelection.
Note that the group shape must have been previously created before calling these methods. Shapes can only
be added to a group programmatically.
When a shape is added to a group, it is removed from the layer it resided on. A group is similar to
a layer in that all shapes contained by a group take on the color state of the group unless they have
their own.
Shapes cannot be added to another group if they already belong to a group. The exception is that a
group shape can contain other group shapes.
Ungrouping and Removing Shapes from a Group
To remove a single shape from a group, call GroupRemoveShape.
To remove all shapes from a group, call GroupRemoveAll.
When a shape is removed from a group, it is placed onto the current layer (see LayerNumber).
The shape then takes on the color state of the layer, unless it has its own color state.
When all shapes are removed from a group, note that the group shape itself still exists. To explicitly
delete a group shape, call ShapeDelete.
If a group shape is deleted, all shapes contained by the group are also deleted.
Determining if a Shape is Contained by a Group
To determine if a shape is contained by a group, call ShapeOnGroup.
This method returns the group number a shape resides on.
Returning the Shapes Contained by a Group
The property GroupShapeNumbers returns an array of shape numbers of the shapes contained by a group.
See Also
Group Routines, Shape Selection Overview, Colors Overview, Group Shapes and Flowchart Behavior
![]() |
Last modified on: Tuesday, February 04, 2003