Back to Devexpress

SpreadsheetControl.BeforeFillRange Event

wpf-devexpress-dot-xpf-dot-spreadsheet-dot-spreadsheetcontrol-5dc010b3.md

latest3.7 KB
Original Source

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.v25.2.dll

NuGet Package : DevExpress.Wpf.Spreadsheet

Declaration

csharp
public event BeforeFillRangeEventHandler BeforeFillRange
vb
Public Event BeforeFillRange As BeforeFillRangeEventHandler

Event Data

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

PropertyDescription
CancelGets or sets whether to cancel the fill operation for the current cell range.
OperationTypeGets the fill operation type.
SourceRangeReturns a cell range based on which a user fills the adjacent cells.
TargetRangeReturns 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:

csharp
spreadsheetControl.BeforeFillRange += (s, e) => {
    CellRange destRange = e.TargetRange.Exclude(e.SourceRange);

    foreach (Cell cell in destRange.ExistingCells)
    {
        if (!cell.Value.IsEmpty)
            e.Cancel = true;
    }
};
vb
AddHandler spreadsheetControl.BeforeFillRange,
    Sub(s, e)
        Dim destRange As CellRange = e.TargetRange.Exclude(e.SourceRange)

        For Each cell As Cell In destRange.ExistingCells
            If Not cell.Value.IsEmpty Then
                e.Cancel = True
            End If
        Next cell
    End Sub

The AfterFillRange event is raised when the fill operation is completed.

See Also

BeforeDragRange

AfterFillRange

SpreadsheetControl Class

SpreadsheetControl Members

DevExpress.Xpf.Spreadsheet Namespace