Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

SpreadsheetControl.BeforeDropRange Event

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

Namespace: DevExpress.XtraSpreadsheet

Assembly: DevExpress.XtraSpreadsheet.v24.2.dll

NuGet Package: DevExpress.Win.Spreadsheet

#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];
// ...

spreadsheetControl1.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