# Resizing the Data to Fit the Cell

Learn how to use the shrink to fit option to display all text in a cell with these practical examples and code snippets.

## Content

You can display all the text in the cell with the shrink to fit option. The font size is reduced if the text is too long for the visible area of the cell.
This property is available for the currency, datetime, mask, number, percent, regular expression, text, or general cell.
The following image shows the difference between a cell with the [ShrinkToFit](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.CellType.EditBaseCellType.ShrinkToFit.html) property set to True and a cell with the property set to False.
![An image displaying spreadsheet cells with and without the shrink to fit option](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/shrinktofit.png)

## Using Code

1. Create a cell that supports the shrink to fit option such as the regular expression cell.
2. Set the **ShrinkToFit** property.
3. Set the **CellType** property.
4. Type a valid value for the cell such as 11240082777 for the regular expression cell in this example.

## Example

This example reduces the font size so the text is displayed in the cell.

```csharp
FarPoint.Win.Spread.CellType.RegularExpressionCellType testcell = new FarPoint.Win.Spread.CellType.RegularExpressionCellType();
testcell.ShrinkToFit = true;
testcell.RegularExpression = "^\\d{11}$";
fpSpread1.Sheets[0].Cells[0, 0].CellType = testcell;
```

```vbnet
Dim testcell As New FarPoint.Win.Spread.CellType.RegularExpressionCellType()
testcell.ShrinkToFit = True
testcell.RegularExpression = "^\d{11}$"
fpSpread1.Sheets(0).Cells(0, 0).CellType = testcell
```

## Using the Spread Designer

1. Select the cell or cells in the work area.
2. In the property list, in the **Misc** category, select **CellType**. From the drop-down list, choose the cell type.
3. Expand the **CellType** property and set the **ShrinkToFit** property to True.
4. From the **File** menu choose **Apply and Exit** to apply your changes to the component and exit Spread Designer.

## See Also

[Allowing Cell Data to Overflow](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-cell/spwin-celldata/spwin-celloflow)
[Aligning Cell Contents](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-cell/spwin-celldata/spwin-cellalign)
[Resizing a Cell to Fit the Data](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-cell/spwin-celldata/spwin-cellfitdata)