Search
Single and Multiple Selection

Selecting and modifying items

In order to move or modify a diagram item, users manipulate its selection handles. The handles appear around an object when it is selected. Each handle can be dragged to perform specific transformation on the object. The appearance and behavior of modification handles can be altered via the SelStyle property of item classes. According to the value of ModificationStart property those handles can also appear automatically if the mouse pointer hovers over an object. It is possible to implement own drawing and hit-testing of selection handles by assigning sstCustom to SelStyle and handling the DrawSelHandles and HitTestSelHandles events.

Multiple selection

Multiple items can be selected and moved at the same time. Moving multiple items raises the SelectionMoved event. Multiple selection can be enabled or disabled via AllowMultiSel. The visual style of multiple selection is defined through the MultiSelStyle property. Additional properties for customizing multiple selection are exposed via SelectionOptions.

SelectionOnTop 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. One of the objects in the selection is always regarded to as the active object (the last selected item in multiple selection). It has white modification handles, while the other items in the multiple-selection have gray ones. When displaying an object property page, it shows the properties of the current active object.

Accessing selected objects

To iterate over selected items use SelectedArrows, SelectedBoxes and SelectedTables collections. To access the current active object use ActiveArrowActiveBox or ActiveTable properties. Check the ActiveItemType property to get the current active item type. To determine if an object is selected refer to Box.Selected, Table.Selected or respectively Arrow.Selected properties.

Manipulating selection programmatically

The following methods programmatically manage selection:

Method

Description

AddToSelection

Selects the object specified as argument or adds it to multiple-selection if other objects are selected too.

ClearSelection

Clears selection (does not delete objects).

RemoveFromSelection

Removes the object specified as argument from the selection.

Selection-related events

The events listed below are raised in response to users selecting or deselecting items. In addition, the SelectionChanged event is raised each time the selection is updated.

Event

Description

BoxSelected

Raised when a box becomes the active object.

BoxSelectionLost

Raised when a box is no more the active object.

TableSelected

Raised when a table becomes the active object.

TableSelectionLost

Raised when a table is no more the active object.

ArrowSelected

Raised when an arrow becomes the active object.

ArrowSelectionLost

Raised when an arrow is no more the active object.

RequestSelectBox

Raised when a box is about to be selected by the user.

RequestSelectArrow

Raised when an arrow is about to be selected by the user.

RequestSelectTable

Raised when a table is about to be selected by the user.

SelObjAdded

Raised when an object is added to multiple selection.

SelObjRemoved

Raised when an object is removed from multiple selection.

Automatically selecting objects

Setting SelectAfterCreate property to true automatically selects all newly created objects. In similar manner setting SelectAfterPaste to true will automatically select objects when they are pasted.