# Best Fit | WinForms Controls | DevExpress Documentation

The [PivotGridControl](/WindowsForms/DevExpress.XtraPivotGrid.PivotGridControl) control can use the Best Fit feature to calculate and apply the optimal column width to fit its content.

## Best Fit Overview

The **Best Fit** feature can be applied to an individual column and all columns in the PivotGridControl

Use the [PivotGridControl.BestFit](/WindowsForms/DevExpress.XtraPivotGrid.PivotGridControl.BestFit.overloads) method without parameters to apply the Best Fit feature to all columns.

Use the [PivotGridControl.BestFit](/WindowsForms/DevExpress.XtraPivotGrid.PivotGridControl.BestFit.overloads) method with a [PivotGridField](/WindowsForms/DevExpress.XtraPivotGrid.PivotGridField) parameter (or the [PivotGridField.BestFit](/WindowsForms/DevExpress.XtraPivotGrid.PivotGridField.BestFit) method) to specify the field whose columns should be automatically adjusted.

The following table lists the methods used to apply the Best Fit feature:

| Method | Description |
| --- | --- |
| [PivotGridControl.BestFit](/WindowsForms/DevExpress.XtraPivotGrid.PivotGridControl.BestFit.overloads) | Depending on the specific overload, applies the Best Fit feature to all columns or to the columns that correspond to the specified field. |
| [PivotGridField.BestFit](/WindowsForms/DevExpress.XtraPivotGrid.PivotGridField.BestFit) | Resizes the field’s column(s) to fit the longest text currently displayed in the column. |
| [PivotGridControl.BestFitColumnArea](/WindowsForms/DevExpress.XtraPivotGrid.PivotGridControl.BestFitColumnArea) | Resizes columns in the [Data Area](/WindowsForms/1693/controls-and-libraries/pivot-grid/ui-elements/data-area) to the minimum width required to display their contents. |
| [PivotGridControl.BestFitRowArea](/WindowsForms/DevExpress.XtraPivotGrid.PivotGridControl.BestFitRowArea) | Resizes columns that display [row field](/WindowsForms/1709/controls-and-libraries/pivot-grid/ui-elements/row-field) values to the minimum width required to display their contents. |
| [PivotGridControl.BestFitDataHeaders](/WindowsForms/DevExpress.XtraPivotGrid.PivotGridControl.BestFitDataHeaders%28System.Boolean%29) | Resizes the [Data Header Area](/WindowsForms/1688/controls-and-libraries/pivot-grid/ui-elements/data-header-area) to the minimum width required to display data field headers. |

To disable the Best Fit feature, set the [PivotGridOptionsBehaviorBase.BestFitMode](/CoreLibraries/DevExpress.XtraPivotGrid.PivotGridOptionsBehaviorBase.BestFitMode) property to [PivotGridBestFitMode.None](/CoreLibraries/DevExpress.XtraPivotGrid.PivotGridBestFitMode).

Note

The Best Fit feature cannot be applied within the [PivotGridControl.BeginUpdate](/WindowsForms/DevExpress.XtraPivotGrid.PivotGridControl.BeginUpdate) and [PivotGridControl.EndUpdate](/WindowsForms/DevExpress.XtraPivotGrid.PivotGridControl.EndUpdate) method calls.

## End-User Capabilities

End-users can resize columns to the optimal width by double-clicking the column’s right border.

![EndUserCapabilities_ResizingColumns](/WindowsForms/images/endusercapabilities_resizingcolumns18562.gif)

Tip

If you do not want the end-users to resize columns, set the [PivotGridOptionsCustomizationEx.AllowResizing](/WindowsForms/DevExpress.XtraPivotGrid.PivotGridOptionsCustomizationEx.AllowResizing) property to **false**.

## Best Fit Options

You can use the [PivotGridOptionsBehaviorBase.BestFitMode](/CoreLibraries/DevExpress.XtraPivotGrid.PivotGridOptionsBehaviorBase.BestFitMode) property to specify which visual elements are considered when calculating the optimal column width. The column width is calculated based on the content of data cells, field values and field headers.

To calculate column width using the Best Fit algorithm for dragged and dropped fields, use the [PivotGridOptionsBehavior.ApplyBestFitOnFieldDragging](/WindowsForms/DevExpress.XtraPivotGrid.PivotGridOptionsBehavior.ApplyBestFitOnFieldDragging) property.

If you handle the [PivotGridControl.CustomAppearance](/WindowsForms/DevExpress.XtraPivotGrid.PivotGridControl.CustomAppearance) event, set the [PivotGridOptionsBehavior.BestFitConsiderCustomAppearance](/WindowsForms/DevExpress.XtraPivotGrid.PivotGridOptionsBehavior.BestFitConsiderCustomAppearance)  property to **true** to consider new appearance settings specified in the event handler. Note that Best Fit performs slower if the [PivotGridOptionsBehavior.BestFitConsiderCustomAppearance](/WindowsForms/DevExpress.XtraPivotGrid.PivotGridOptionsBehavior.BestFitConsiderCustomAppearance) property is set to **true**.