Search
Attaching and Grouping Items

Overview

FlowChartX allows attaching a node to another diagram element, establishing a subordinate - master relationship between the two objects. When a master element is moved or resized, any subordinated node follows it, so that the initial distance between the two objects stays constant. This happens both when a user moves the master object around, and when the object position is changed using a method or a property.

Possible uses

  • attach a Transparent box to another node or link and set its Text, so that the box acts as an additional label assigned to the main object.
  • attach a box to another object and set the box' Picture, so it acts as an additional icon displayed inside or near the main object.
  • attach a box or a table to another object and handle the BoxClicked or similar events to perform some action on the main object. This makes the subordinated object act as a button or another type of UI element attached to the main object. For more complex UI  requirements, use attached boxes of Style bsAxControl and handle the events raised by the hosted control.
  • in all cases above, the Locked property can be set for attached nodes which are used only as decorations embellishing the main object. That prevents users from selecting, modifying or drawing links to the subordinates.
  • attach child elements in a tree branch to the branch root, so that when a user moves a tree node, the node's children moves simultaneously with it. Modifying an object in such hierarchical group makes the modification pervade through all dependant subordinated objects.

Hierarchical grouping

An unit of attached objects is managed by creating and manipulating a Group instance. To create a group with a specific master object, call the CreateGroup method and use the Group methods to attach items. Every member of a group can be the master object of another group, i.e. an item can be subordinate in one group and meanwhile be another group's master. FlowChartX doesn't impose any limits to the depth and width of group hierarchies built that way. However, it is not possible to put an item as a subordinate in more than one groups because the hierarchy relations would become ambiguous.

Unions

It is possible to create such groups, that if any item in the hierarchy is modified, all other items are updated too. This can be done by putting the items in circular chain of dependencies - i.e. object1 is attached to object2, object2 to object3 ... objectN to object1. If any of these objects is modified, the change will propagate through the chain until it reaches its originator.

Attaching items to a group

Arrows cannot be attached to groups but can be main objects of groups. If a group's main object is an arrow, nodes can be attached to the control points or segments of the arrow. See the AttachToArrowPoint, AttachToArrowSegment and AttachToLongestHSegment methods for details. If the master object is a node, other nodes can be attached to any of its corners, or to an area specified as percent of master-node's bounding rectangle. Check AttachToCorner and AttachProportional for details.

Accessing group items

Group members can be accessed using the MainObject property and the AttachedBoxes / AttachedTables collections. To get the groups in which an item participates, use its MasterGroup and SubordinateGroup properties.

Destroying groups

Groups can be destroyed programmatically using the DestroyGroup method. When a user deletes the main object of a group, the group is destroyed automatically but the attached objects are not deleted. If you need to delete them with the group, you could do this programmatically in the method that handles the GroupDestroyed event. That event is raised just before the group's memory is freed so in the handler method you are still able to enumerate the attached objects. The following VB example shows how this can be done:

VB  Copy Code

Private Sub fc_GroupDestroyed(ByVal group As FLOWCHARTLibCtl.IGroupItem)

    Dim i As Integer
    Dim l As Integer

    Dim boxes As FLOWCHARTLibCtl.IBoxes
    Set boxes = group.AttachedBoxes

    l = boxes.Count

    For i = 0 To l - 1
        fc.DeleteItem boxes(i)
    Next i

End Sub