# Filling Cells with Drag and Fill

## Content

You can allow users to drag and fill data from one cell or a selected range to adjacent cells. With a cell or range of cells selected, users can drag to fill horizontally (across columns) or vertically (across rows).
To enable drag fill, set the [AllowDragFill](/spreadnet/api/latest/online-wpf/GrapeCity.Wpf.SpreadSheet/GrapeCity.Wpf.SpreadSheet.GcSpreadSheet.AllowDragFill.html) property of the [GcSpreadSheet](/spreadnet/api/latest/online-wpf/GrapeCity.Wpf.SpreadSheet/GrapeCity.Wpf.SpreadSheet.GcSpreadSheet.html) class to true. When enabled, a fill handle appears at the bottom-right corner of the selected cell or range. Dragging the fill handle to adjacent cells initiates the drag fill operation.
By default, a context menu button appears during the drag operation. To hide this button, set the [ShowContextMenu](/spreadnet/api/latest/online-wpf/GrapeCity.Wpf.SpreadSheet/GrapeCity.Wpf.SpreadSheet.DragFillEventArgs.ShowContextMenu.html) property to false in the [DragFillStarting](/spreadnet/api/latest/online-wpf/GrapeCity.Wpf.SpreadSheet/GrapeCity.Wpf.SpreadSheet.GcSpreadSheet.DragFillStarting.html) event.
![image](https://cdn.mescius.io/document-site-files/images/7c6eedf3-2c66-498d-adc9-344d7f4b659a/image-20260421.e9eafc.png)

## Auto Fill Options

The available AutoFill options in the drag fill context menu depend on the selected data type.
You can select a fill type from the drag fill dropdown menu displayed after dragging.

| Option | Description |
| ------ | ----------- |
| Copy Cells | Copies the selected data to the target range. |
| Fill Series | Increments or decrements values based on a detected series. Drag downward or to the right to increment values; drag upward or to the left to decrement values.<br>**Note**: When using Fill Series, the component evaluates the data model to determine whether the selected data can be extended as a series. If a built-in cell type is applied, the displayed values take precedence over the underlying data model when generating the series. |
| Fill Formatting Only | Applies only the formatting of the source cells to the target range without copying values. |
| Fill Without Formatting | Copies values without applying source formatting. |
| Fill Days | Extends days from the source range to the target range. Formatting is copied. |
| Fill Weekdays | Extends workweek day names to the target range. Formatting is copied. |
| Fill Months | Extends months to the target range. Formatting is copied. |
| Fill Years | Extends years to the target range. Formatting is copied. |

## Context Menu Items by Data Type

**If the selected data can be extended as a series**
The context menu contains:

1. Copy Cells
2. Fill Series
3. Fill Formatting Only
4. Fill Without Formatting

If the data is in a date format, the following additional options are available:

5. Fill Days
6. Fill Weekdays
7. Fill Months
8. Fill Years

The default selected option is Fill Series.
**If the selected data cannot be extended as a series**
The context menu contains:

1. Copy Cells
2. Fill Formatting Only
3. Fill Without Formatting

The default selected option is Copy Cells.
The following examples use the fill copy option.
![image](https://cdn.mescius.io/document-site-files/images/7c6eedf3-2c66-498d-adc9-344d7f4b659a/image-20260421.b172a7.png)
The following example uses the fill series option.
![image](https://cdn.mescius.io/document-site-files/images/7c6eedf3-2c66-498d-adc9-344d7f4b659a/image-20260421.acc9c8.png)
The following example uses the fill months option.
![image](https://cdn.mescius.io/document-site-files/images/7c6eedf3-2c66-498d-adc9-344d7f4b659a/image-20260421.d12f60.png?width=450)
You can customize the fill behavior by using the [FillRange](/spreadnet/api/latest/online-wpf/GrapeCity.Wpf.SpreadSheet/GrapeCity.Wpf.SpreadSheet.DragFillEventArgs.FillRange.html) EventArgs.
For more information on event arguments, refer to [DragFillStarting](/spreadnet/api/latest/online-wpf/GrapeCity.Wpf.SpreadSheet/GrapeCity.Wpf.SpreadSheet.GcSpreadSheet.DragFillStarting.html) event and [DragFillEventArgs](/spreadnet/api/latest/online-wpf/GrapeCity.Wpf.SpreadSheet/GrapeCity.Wpf.SpreadSheet.DragFillEventArgs.html).

## Using Code

Refer to the following example code that shows how to enable drag fill in both XAML view and in the code view.
**XAML**

```xml
<Grid>
    <gss:GcSpreadSheet x:Name="GcSpreadSheet1" AllowDragFill="True"/>
</Grid>
```

**C#**

```csharp
spreadSheet.AllowDragFill = true;
```

**VB**

```vbnet
spreadSheet.AllowDragFill = True
```