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.BeforeFillRange Event

Occurs when a user drags the fill handle to populate cells with data based on values in the source range.

Namespace: DevExpress.Xpf.Spreadsheet

Assembly: DevExpress.Xpf.Spreadsheet.v24.2.dll

NuGet Package: DevExpress.Wpf.Spreadsheet

#Declaration

public event BeforeFillRangeEventHandler BeforeFillRange

#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:

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

See Also