Search
Managing and Accessing Diagram Items

Creating objects

There are several methods for creating objects of the basic types supported by the component. The CreateBox method creates a box at a specified position. The CreateTable method creates a table at a specified position. Use the CreateArrow or CreateAnchoredArrow method to create an arrow between two boxes; use CreateRelation to create an arrow between two tables. To link box to a table call CreateLink. Tables have method that connects them with other tables called AddRelation.

Deleting objects

Call the DeleteItem method to delete an object from the diagram. The ClearAll method clears diagram contents by deleting all objects. To break the relation (delete the arrow) between two tables you might call Table.BreakRelation.

Accessing existing objects

One of the most common tasks performed when using the control is iterating over all objects in the flowchart document. To enumerate all items in the diagram, use the Arrows, Boxes and Tables collections.

Navigating the diagram

There are many properties and methods that let you navigate through the object hierarchy - from a node to its incoming or outgoing arrows, or from an arrow to its origin and destination nodes. The nodes that an arrow connects are referenced by the arrow's Origin and Destination properties. Alternatively, you can use the type-safe DestinationBox and OriginBox properties if the arrow connects boxes, or DestinationTable and OriginTable properties for tables. To check the type of arrow's origin and destination use OriginType and DestinationType. To access the arrows that are connected to a box, use its IncomingArrows and OutgoingArrows collections. The first collection contains references to all arrows pointing to a box, the second - to the arrows that start from a box. Arrows connect to rows of a table; to find all arrows connected with a table its GetRowOutgoingArrows and GetRowIncomingArrows methods have to be used. A shortcut for accessing the other end of a relation in entity-relationship diagrams is provided by the GetRelatedTables method.

Selected objects

If just a single item in the diagram is selected, it is considered the active item and can be accessed with the ActiveArrow, ActiveBox or ActiveTable property. The ActiveItemType property indicates the type of the active object. Multiple items can be selected when clicking or dragging with the CTRL key pressed at the same time. Access to the items in multiple selection is provided through the SelectedArrows, SelectedBoxes and SelectedTables collections.

Finding objects

You can search for items by their tag using the FindArrow, FindBox and FindTable methods. If there are more objects with the same tag, the first one will be returned. If no object with the specified tag exists, the HRESULT will be S_FALSE and null object reference will be returned. Groups can also be searched by tag using FindGroup.