Using Drag Fill
Spread WinRT Documentation > Developer's Guide > Managing the User Interface > Using Drag Fill

GcSpreadSheet has a drag fill option that allows the user to select cells and fill other cells with the same or different values. The fill type can be set to linear, growth, date, or automatic fill. The fill direction can also be specified. Additional options can be set such as step and stop values.

Select a cell or block and move the mouse pointer over the square at the corner of the selection. The mouse pointer changes to a double arrow that can be used to expand the fill range. Click on the plus mark to display a menu with additional fill options as shown in the following image:

Drag fill is not supported if the destination range contains a spanned cell. Drag fill does not apply to a conditional format or filtered range.

The CanUserDragFill property is used to specify whether to allow drag fill. The FillAuto method, FillDate method, FillGrowth method, or FillLinear method can be used to programmatically specify the type of fill.

Using Code

This example fills the cells with data using a series.

CS
Copy Code
private void Grid_Loaded_1(object sender, RoutedEventArgs e)
        {
            gcSpreadSheet1.CanUserDragFill = true;
            gcSpreadSheet1.Sheets[0].SetValue(0, 0, new DateTime(2011, 1, 1));
            gcSpreadSheet1.Sheets[0].SetValue(0, 1, new DateTime(2011, 2, 9));
            gcSpreadSheet1.Sheets[0].SetValue(0, 2, 5);
            gcSpreadSheet1.Sheets[0].SetValue(0, 3, 10);
            gcSpreadSheet1.Sheets[0].SetValue(0, 4, 1);
        }
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            GrapeCity.Xaml.SpreadSheet.Data.CellRange r = new GrapeCity.Xaml.SpreadSheet.Data.CellRange(0, 0, 4, 1);
            gcSpreadSheet1.Sheets[0].FillDate(r, GrapeCity.Xaml.SpreadSheet.Data.FillSeries.Column, GrapeCity.Xaml.SpreadSheet.Data.FillDateUnit.Day, 2);
            GrapeCity.Xaml.SpreadSheet.Data.CellRange r2 = new GrapeCity.Xaml.SpreadSheet.Data.CellRange(0, 1, 4, 1);
            gcSpreadSheet1.Sheets[0].FillDate(r2, GrapeCity.Xaml.SpreadSheet.Data.FillSeries.Column, GrapeCity.Xaml.SpreadSheet.Data.FillDateUnit.Day, 1, new DateTime(2011, 2, 11));
            GrapeCity.Xaml.SpreadSheet.Data.CellRange r3 = new GrapeCity.Xaml.SpreadSheet.Data.CellRange(0, 2, 4, 1);
            //gcSpreadSheet1.Sheets[0].FillAuto(r3, GrapeCity.Xaml.SpreadSheet.Data.FillDirection.Down);
            gcSpreadSheet1.Sheets[0].FillAuto(r3, GrapeCity.Xaml.SpreadSheet.Data.FillSeries.Column);
            GrapeCity.Xaml.SpreadSheet.Data.CellRange r4 = new GrapeCity.Xaml.SpreadSheet.Data.CellRange(0, 3, 4, 1);
            //gcSpreadSheet1.Sheets[0].FillGrowth(r4, GrapeCity.Xaml.SpreadSheet.Data.FillSeries.Column);
            //gcSpreadSheet1.Sheets[0].FillGrowth(r4, GrapeCity.Xaml.SpreadSheet.Data.FillSeries.Column, 2);
            gcSpreadSheet1.Sheets[0].FillGrowth(r4, GrapeCity.Xaml.SpreadSheet.Data.FillSeries.Column, 2, 55);
            GrapeCity.Xaml.SpreadSheet.Data.CellRange r5 = new GrapeCity.Xaml.SpreadSheet.Data.CellRange(0, 4, 4, 1);
            //gcSpreadSheet1.Sheets[0].FillLinear(r5, GrapeCity.Xaml.SpreadSheet.Data.FillSeries.Column);
            //gcSpreadSheet1.Sheets[0].FillLinear(r5, GrapeCity.Xaml.SpreadSheet.Data.FillSeries.Column, 3);
            gcSpreadSheet1.Sheets[0].FillLinear(r5, GrapeCity.Xaml.SpreadSheet.Data.FillSeries.Column, 3, 20);   
        }
VB
Copy Code
Private Sub MainPage_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
        gcSpreadSheet1.CanUserDragFill = True
        gcSpreadSheet1.Sheets(0).SetValue(0, 0, New DateTime(2011, 1, 1))
        gcSpreadSheet1.Sheets(0).SetValue(0, 1, New DateTime(2011, 2, 9))
        gcSpreadSheet1.Sheets(0).SetValue(0, 2, 5)
        gcSpreadSheet1.Sheets(0).SetValue(0, 3, 10)
        gcSpreadSheet1.Sheets(0).SetValue(0, 4, 1)
    End Sub
    Private Sub Button_Click_1(sender As Object, e As RoutedEventArgs)
        Dim r As New GrapeCity.Xaml.SpreadSheet.Data.CellRange(0, 0, 4, 1)
        gcSpreadSheet1.Sheets(0).FillDate(r, GrapeCity.Xaml.SpreadSheet.Data.FillSeries.Column, GrapeCity.Xaml.SpreadSheet.Data.FillDateUnit.Day, 2)
        Dim r2 As New GrapeCity.Xaml.SpreadSheet.Data.CellRange(0, 1, 4, 1)
        gcSpreadSheet1.Sheets(0).FillDate(r2, GrapeCity.Xaml.SpreadSheet.Data.FillSeries.Column, GrapeCity.Xaml.SpreadSheet.Data.FillDateUnit.Day, 1, New DateTime(2011, 2, 11))
        Dim r3 As New GrapeCity.Xaml.SpreadSheet.Data.CellRange(0, 2, 4, 1)
        'gcSpreadSheet1.Sheets(0).FillAuto(r3, GrapeCity.Xaml.SpreadSheet.Data.FillDirection.Down)
        gcSpreadSheet1.Sheets(0).FillAuto(r3, GrapeCity.Xaml.SpreadSheet.Data.FillSeries.Column)
        Dim r4 As New GrapeCity.Xaml.SpreadSheet.Data.CellRange(0, 3, 4, 1)
        'gcSpreadSheet1.Sheets(0).FillGrowth(r4, GrapeCity.Xaml.SpreadSheet.Data.FillSeries.Column)
        'gcSpreadSheet1.Sheets(0).FillGrowth(r4, GrapeCity.Xaml.SpreadSheet.Data.FillSeries.Column, 2)
        gcSpreadSheet1.Sheets(0).FillGrowth(r4, GrapeCity.Xaml.SpreadSheet.Data.FillSeries.Column, 2, 55)
        Dim r5 As New GrapeCity.Xaml.SpreadSheet.Data.CellRange(0, 4, 4, 1)
        'gcSpreadSheet1.Sheets(0).FillLinear(r5, GrapeCity.Xaml.SpreadSheet.Data.FillSeries.Column)
        'gcSpreadSheet1.Sheets(0).FillLinear(r5, GrapeCity.Xaml.SpreadSheet.Data.FillSeries.Column, 3)
        gcSpreadSheet1.Sheets(0).FillLinear(r5, GrapeCity.Xaml.SpreadSheet.Data.FillSeries.Column, 3, 20)     
    End Sub
See Also