One of the most common tasks when using the component is iterating over all items in the diagram document or navigating through the connections between items - from a node to the incoming or outgoing links, or from a link to its origin and destination nodes. To enumerate items of a diagram use the Items, Links or Nodes collections. The nodes that a link connects are referenced by the link's Destination and Origin properties. To access the links that are connected to a node, use its IncomingLinks and OutgoingLinks collections. The first collection contains references to all links pointing to the node, the second - to the links that start from it. Links can connect to rows of a table; to find such links use table's Rows collection and the IncomingLinks and OutgoingLinks collections. A shortcut for accessing the other end of a relation in entity-relationship diagrams is provided by the RelatedOneToMany and RelatedManyToOne properties of the Row class.
If only one item is selected, it is considered the active item and can be accessed with the ActiveItem property. The type of this property is DiagramItem; you can get the actual type of the selected item through .NET reflection. Multiple items can be selected when clicking or dragging with the CTRL key pressed at the same time. Multiple selection is represented by the Selection property of the Diagram class. The Selection object provides collections to access the selected Links and Nodes.
You can search for diagram items by their Tag or Id using the FindLink, FindNode, FindLinkById and FindNodeById methods. Tag and id objects are compared by calling the Equals method of the System.Object class. Thus if they are of value type, they are compared by value (that is bitwise equality). If they are of reference type their Equals method is used. If there are more items with the same tag, the first one will be returned. If no item with the specified tag or id exists, a null reference (Nothing in Visual Basic) will be returned. Groups can also be searched by tag using FindGroup.
The Query method traverses the graph by following node/link connections and group's parent/child relationships to find items in specific relation to the current one. The method receives a string argument consisting of selectors and optional predicates. The query is executed in several steps. In each step the result set is constructed from the previous result set by following the relationship specified by the current selector. If a predicate is specified after the selector identifier, the result set is filtered to include only items for which the predicate evaluates to true.