Search
Single and Multiple Selection

Selecting and Modifying Items

In order to move or modify a diagram element, users manipulate its modification handles. Modification handles appear around an item when it is selected. Each handle can be dragged to perform specific transformation on the item. The appearance and behavior of modification handles can be altered by the HandlesStyle property. Depending on the value assigned to ModificationStart, those handles can also appear automatically when the mouse pointer hovers over an item.

Active Item

If only one diagram item is selected, it is considered the 'active' item. One of the items in a multiple-selection is also regarded as active; it is usually the one selected last. The active item has white modification handles drawn around it, while other items in multiple-selection have gray handles. The active item is probably the one users are most interested in while editing a diagram, and your program can update its state and user-interface according to that. Access to the active item is provided by the ActiveItem property of the Diagram class.

Multiple-Selection

Selection of diagram items in NetDiagram is represented by an instance of the Selection class. This class provides methods to programmatically select or deselect items and properties that specify how the selection looks and behaves. A property of the Diagram class, also called Selection, exposes the items selected within the current document. Multiple items can be selected, thus moved at the same time. To programmatically add or remove items to the multiple-selection, invoke one of the AddItem, Toggle and RemoveItem methods. The Clear method deselects all items and the Change method selects a single item deselecting all other. Setting AllowMultipleSelection to false disables multiple-selection.

Drawing a Selection Rectangle

To select multiple items, users must draw a selection rectangle with the left mouse button while holding down the CTRL key.

Appearance

The visual style of multiple-selection is defined by the Style property of the Selection class. For example selection might be painted as a dashed rectangle or a semi-transparent filled rectangle. Colors of the selection rectangle can be changed by setting the selection's Pen and Brush properties. Another property related to selection visualization is the diagram's SelectionOnTop, which specifies whether selected items should be painted according to their Z-order position or they should be painted on top of the non-selected items.

Enumerating Items

The Selection class exposes the selected items as .NET collections. The Items collection references all selected items, getting them as DiagramItem instances. The Nodes and Links collections keep references to the selected items of specific classes. Alternatively you might enumerate all items in the diagram and check their Selected property.

Automatic Selection

Setting the SelectAfterCreate property to true automatically selects each newly created item, so users can modify it immediately.