Back to Devexpress

PivotGridControl.BestFit(FieldArea) Method

wpf-devexpress-dot-xpf-dot-pivotgrid-dot-pivotgridcontrol-dot-bestfit-x28-devexpress-dot-xpf-dot-pivotgrid-dot-fieldarea-x29.md

latest3.5 KB
Original Source

PivotGridControl.BestFit(FieldArea) Method

Resizes the columns and rows which correspond to the fields contained within the specified area, to the minimum width and height required to completely display their contents.

Namespace : DevExpress.Xpf.PivotGrid

Assembly : DevExpress.Xpf.PivotGrid.v25.2.dll

NuGet Package : DevExpress.Wpf.PivotGrid

Declaration

csharp
public void BestFit(
    FieldArea area
)
vb
Public Sub BestFit(
    area As FieldArea
)

Parameters

NameTypeDescription
areaFieldArea

A FieldArea enumeration value that specifies the PivotGridControl’s field area.

|

Remarks

The BestFit method resizes the column(s) that correspond to the fields displayed within the specified area (Row Header Area or Column Header Area), to entirely display their contents. The BestFit method takes into account:

  • a field header’s width;
  • field values;
  • summary values displayed within the columns that correspond to data fields.

Note

The Best Fit is available only after the Pivot Grid Control has been loaded in the visual tree.

To learn more, see Best Fit.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the BestFit(FieldArea) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-pivot-grid-show-top-n-values-in-context-menu/CS/ContextMenuToShowTopN_Example/MainWindow.xaml.cs#L134

csharp
{
    pivotGridControl1.BestFit(FieldArea.ColumnArea);
}

wpf-pivot-grid-show-top-n-values-in-context-menu/VB/ContextMenuToShowTopN_Example/MainWindow.xaml.vb#L124

vb
Private Sub PivotGridControl1_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
    pivotGridControl1.BestFit(FieldArea.ColumnArea)
End Sub

See Also

PivotGridControl Class

PivotGridControl Members

DevExpress.Xpf.PivotGrid Namespace