# Filling Cells with Drag and Fill

Learn how to use drag-and-fill feature to efficiently fill cells in your spreadsheets with our comprehensive guide.

## Content

You can also allow the end user to drag-and-fill data from one cell or a range of cells to another cell or range of cells. With a cell or range of cells selected, you can fill other cells either in a row (or rows if more than one column is selected) or a column (or columns if more than one row is selected).
In order to fill cells with drag and fill, the [AllowDragFill](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.FpSpread.AllowDragFill.html) property in the [FpSpread](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.FpSpread.html) class must be set to true. In order to show the drag fill button and the drag fill context menu, the [EnableDragFillMenu](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.FpSpread.EnableDragFillMenu.html) property must be set to true.
You can also specify the type of fill you want by using the [RangeDragFillMode](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.FpSpread.RangeDragFillMode.html) property that allows you to choose from the following options in the drag fill drop down context menu icon that appears on your screen:

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

The Copy Cells option copies the data to the selected range. The Fill Series option increments or decrements the values based on the series. Drag down or to the right to increment the values. Drag up or to the left to decrement the values. Spread uses the data model to determine whether the data can be incremented when using the series fill. The displayed values have a higher priority with the built-in cell types when using the series fill. The Fill Formatting Only option and the Fill Without Formatting option allows you to fill cells with or without the same formatting as in the originally selected cell.
The AutoFill options that are available in the Drag Fill context menu depends on the type of selected data and the [DragFillDataOnly](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.FpSpread.DragFillDataOnly.html) property.
The example shown below depicts the drag and fill operation that uses the copy option to fill several cells in a column.
![Drag and Fill](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/dragfill_1.png)
![Drag and Fill](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/drag_fill2.png)
![Drag and Fill](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/drag_fill3.png)
The following example uses the fill series option.
![Filling values in the spreadsheet cells with the fill series option](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/dragfill_5.png)
You can customize the direction of the fill using the [FillDirection](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.FillDirection.html) enumeration.
For more information on event arguments, refer to [DragFillBlock](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.FpSpread.DragFillBlock.html) event, [DragFillBlockEventArgs](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.DragFillBlockEventArgs.html), and [DragFillBlockCompletedEventArgs](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.DragFillBlockCompletedEventArgs.html).

## Using the Properties Window

1. At design time, in the **Properties** window, select the Spread component.
2. Select (in the **Behavior** category) the **AllowDragFill** property.
3. Select **True** from the drop-down list to allow drag-and-fill feature, or select **False** to prohibit it.
4. Select the **EnableDragFillMenu** property.
5. Select **True** from the drop-down list to allow the drag fill button and drag fill context menu, or select **False** to prohibit it.

## Using a Shortcut

Allow the drag-and-fill feature by setting the [AllowDragFill](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.FpSpread.AllowDragFill.html) property in the [FpSpread](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.FpSpread.html) component.
Allow the drag fill button and drag fill context menu by setting the [EnableDragFillMenu](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.FpSpread.EnableDragFillMenu.html) property in the [FpSpread](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.FpSpread.html) component.
**Example**
This example code sets the component to allow the drag-fill feature, drag fill button and the drag fill context menu.

```csharp
fpSpread1.AllowDragFill = true;
fpSpread1.EnableDragFillMenu = true;
```

```vbnet
fpSpread1.AllowDragFill = True
fpSpread1.EnableDragFillMenu = True
```

## Using Code

Allow the drag fill feature by setting the [AllowDragFill](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.FpSpread.AllowDragFill.html) property in the [FpSpread](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.FpSpread.html) component.
Allow the drag fill button and drag fill context menu by setting the [EnableDragFillMenu](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.FpSpread.EnableDragFillMenu.html) property in the [FpSpread](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.FpSpread.html) component.
**Example**
This example code sets the child sheet to allow the drag fill feature, drag fill button and the drag fill context menu.

```csharp
// To enable Drag Fill operation
fpSpread1.ActiveSheet.Reset();           
fpSpread1.DragFillDataOnly = false;
fpSpread1.AllowDragFill = true;
fpSpread1.EnableDragFillMenu = true;
this.fpSpread1.ActiveSheet.Cells[0, 0].Value = "A001";
this.fpSpread1.ActiveSheet.Cells[0, 1].Value = DateTime.Today;
this.fpSpread1.ActiveSheet.Cells[0, 3].Text = "Monday";
```

```vbnet
' To enable Drag Fill operation
fpSpread1.ActiveSheet.Reset()
fpSpread1.DragFillDataOnly = False
fpSpread1.AllowDragFill = True
fpSpread1.EnableDragFillMenu = True
Me.fpSpread1.ActiveSheet.Cells(0, 0).Value = "A001"
Me.fpSpread1.ActiveSheet.Cells(0, 1).Value = DateTime.Today
Me.fpSpread1.ActiveSheet.Cells(0, 3).Text = "Monday"
```

## Using the Spread Designer

1. Select the Spread component (or select **Spread** from the pull-down menu).
2. In the property list for the component (in the **Behavior** category), select the **AllowDragFill** property.
3. Click the drop-down arrow to display the choices and select **True**.
4. In the property list for the component, select the **EnableDragFillMenu** property.
5. Click the drop-down arrow to display the choices and select **True**.
6. From the **File** menu, choose **Apply and Exit** to apply your changes to the component and exit Spread Designer.

> !type=note
> **Note:**
> If the DragFillDataOnly property is set to false and the selected data can be filled as series, all the options will appear in the context menu. If the RangeDragFillMode property is set to Series, then the context menu will show only the Fill Series option and if it is set to Copy, then the context menu will show only the Copy Cells option. If the selected data cannot be filled as series, the context menu will show only three options: Copy Cells, Fill Formatting Only, Fill Without Formatting.
> If the DragFillDataOnly property is set to true and the selected data can be filled as series, the context menu will show only two options: Copy Cells and Fill Series. If the RangeDragFillMode property is set to Series, then the context menu will show only the Fill Series option and if it is set to Copy, then the context menu will show only the Copy Cells option. If the selected data cannot be filled as series, the context menu will show only one option: Copy Cells.

## See Also

[Filling Cells with Drag and Drop](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interactcell/spwin-cell-dragops/spwin-cell-dragdrop)
[Filling Cells with Drag and Move](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interactcell/spwin-cell-dragops/spwin-cell-dragmove)