Skip to main content
A newer version of this page is available. .

SpreadsheetControl.BeforeDropRange Event

Occurs when a user is about to drop the selected cell range in a new location.

Namespace: DevExpress.Xpf.Spreadsheet

Assembly: DevExpress.Xpf.Spreadsheet.v19.1.dll

Declaration

public event BeforeDropRangeEventHandler BeforeDropRange

Event Data

The BeforeDropRange event's data class is BeforeDropRangeEventArgs. The following properties provide information specific to this event:

Property Description
Cancel Gets or sets whether to cancel the drag-and-drop operation for the selected cell range.
OperationType Gets the drag-and-drop operation type.
SourceRange Returns a cell range that a user is about to move or copy to a new location.
TargetRange Returns a cell range into which a user is about to paste data.

Remarks

The BeforeDropRange event fires in the following cases:

  • When a user drags a cell range in a new location in a worksheet (OperationType is MoveCells).

  • When a user drags a cell range in a new location with the Ctrl key pressed. In this case, source cells are copied to the destination range (OperationType is CopyCells).

Set the event’s Cancel parameter to true to cancel the operation. The following example shows how to prevent the move operation for a data table.

Table table = worksheet.Tables[0];
// ...

spreadsheetControl.BeforeDropRange += (s, e) => {
    if (e.OperationType == DragDropOperationType.MoveCells && table.Range.IsIntersecting(e.SourceRange))
        e.Cancel = true;
};

The AfterDropRange event is raised when the drag-and-drop operation is completed.

See Also