SpreadsheetControl.BeforeFillRange Event
Occurs when a user drags the fill handle to populate cells with data based on values in the source range.
Namespace: DevExpress.XtraSpreadsheet
Assembly: DevExpress.XtraSpreadsheet.v24.1.dll
NuGet Package: DevExpress.Win.Spreadsheet
Declaration
Event Data
The BeforeFillRange event's data class is BeforeFillRangeEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Cancel | Gets or sets whether to cancel the fill operation for the current cell range. |
OperationType | Gets the fill operation type. |
SourceRange | Returns a cell range based on which a user fills the adjacent cells. |
TargetRange | Returns a cell range that a user fills with data. |
Remarks
The BeforeFillRange event fires in the following cases:
When a user drags the fill handle to populate the adjacent cells with data based on the source cells’ values (OperationType is FillSeries).
When a user drags the fill handle with the Ctrl key pressed to copy source cells to the destination range (OperationType is CopyCells).
The event’s Cancel parameter allows you to cancel the operation. The following example shows how to cancel the fill operation if destination cells already contain data:
spreadsheetControl1.BeforeFillRange += (s, e) => {
CellRange destRange = e.TargetRange.Exclude(e.SourceRange);
foreach (Cell cell in destRange.ExistingCells)
{
if (!cell.Value.IsEmpty)
e.Cancel = true;
}
};
The AfterFillRange event is raised when the fill operation is completed.