windowsforms-devexpress-dot-xtraspreadsheet-dot-spreadsheetcontrol-667d71ac.md
Occurs when a user is about to drop the selected cell range in a new location.
Namespace : DevExpress.XtraSpreadsheet
Assembly : DevExpress.XtraSpreadsheet.v25.2.dll
NuGet Package : DevExpress.Win.Spreadsheet
public event BeforeDropRangeEventHandler BeforeDropRange
Public Event BeforeDropRange As BeforeDropRangeEventHandler
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. |
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;
};
Dim table As Table = worksheet.Tables(0)
' ...
AddHandler SpreadsheetControl1.BeforeDropRange,
Sub(s, e)
If e.OperationType = DragDropOperationType.MoveCells AndAlso table.Range.IsIntersecting(e.SourceRange) Then
e.Cancel = True
End If
End Sub
The AfterDropRange event is raised when the drag-and-drop operation is completed.
See Also