In a diagram document, several items can be selected simultaneously. If more than one item is selected, the compound set of selected items is handled by an instance of the Selection class.
Items in the selection can be of any element type. The Items property gives a collection of all the items in the selection. You can get type-safe access to items of specific class by using the Links and Nodes collections properties.
Users can select multiple items by drawing a selection rectangle. Depending on the DiagramView's Behavior, this is done either by simply dragging the mouse, or by holding CTRL down while dragging the mouse. Depending on the IncludeItemsIfIntersect value, items are selected if they are entirely inside the drawn selection rectangle, or if at least a part of them is inside the rectangle. It is possible to prevent users from selecting more than one items at the same time by setting AllowMultipleSelection to false.
Items can be always added or removed programmatically to selection by calling the AddItem and RemoveItem methods. Selection state of an item can be toggled, getting deselected from selected and vice versa, by calling the Toggle method. All items in the selection are deselected if Clear is invoked.
Use the Selected property of the DiagramItem class to determine whether a particular item is selected. The Selection's GetSize method returns how many items are selected. Bounds returns the rectangle that bounds all selected items.
The visual style of multiple selection is defined by the Style property. For example selection might be painted as a dashed rectangle or a semi-transparent filled rectangle.