Back to Devexpress

PivotGridControl.BestFit() Method

wpf-devexpress-dot-xpf-dot-pivotgrid-dot-pivotgridcontrol-e0487b2b.md

latest6.1 KB
Original Source

PivotGridControl.BestFit() Method

Resizes the columns and rows which correspond to the data and row fields, 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()
vb
Public Sub BestFit

Remarks

The BestFit method resizes the column(s) that correspond to the data fields and row fields, 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 snippets (auto-collected from DevExpress Examples) contain references to the BestFit() 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-pivotgrid-how-to-display-underlying-data-asynchronously/CS/WpfDrillDownDataSourceExample/MainWindow.xaml.cs#L36

csharp
pivotGridControl1.BestFitArea = DevExpress.Xpf.PivotGrid.FieldBestFitArea.FieldHeader;
    pivotGridControl1.BestFit();
}

wpf-pivotgrid-customize-the-cell-template/CS/HowToCustomizeCellTemplate/MainWindow.xaml.cs#L20

csharp
pivotGridControl1.BestFitArea = DevExpress.Xpf.PivotGrid.FieldBestFitArea.FieldHeader;
    pivotGridControl1.BestFit();
}

wpf-pivot-grid-define-custom-cell-template-to-performing-data-editing/CS/HowToEditCell/MainWindow.xaml.cs#L22

csharp
pivotGridControl1.DataSource = OrderSourceList;
    pivotGridControl1.BestFit();
}

wpf-pivot-grid-implement-custom-summary/CS/DXPivotGrid_CustomSummary/MainWindow.xaml.cs#L30

csharp
{
    pivotGridControl1.BestFit();
}

wpf-pivot-grid-split-field-value-cells/CS/Window1.xaml.cs#L18

csharp
pivotGrid.DataSource = PivotHelper.GetDataTable();
    pivotGrid.BestFit();
}

wpf-pivotgrid-how-to-display-underlying-data-asynchronously/VB/WpfDrillDownDataSourceExample/MainWindow.xaml.vb#L40

vb
Me.pivotGridControl1.BestFitArea = FieldBestFitArea.FieldHeader
    Me.pivotGridControl1.BestFit()
End Sub

wpf-pivotgrid-customize-the-cell-template/VB/HowToCustomizeCellTemplate/MainWindow.xaml.vb#L21

vb
pivotGridControl1.BestFitArea = DevExpress.Xpf.PivotGrid.FieldBestFitArea.FieldHeader
    pivotGridControl1.BestFit()
End Sub

wpf-pivot-grid-define-custom-cell-template-to-performing-data-editing/VB/HowToEditCell/MainWindow.xaml.vb#L23

vb
pivotGridControl1.DataSource = OrderSourceList
    pivotGridControl1.BestFit()
End Sub

wpf-pivot-grid-implement-custom-summary/VB/DXPivotGrid_CustomSummary/MainWindow.xaml.vb#L29

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

wpf-pivot-grid-split-field-value-cells/VB/Window1.xaml.vb#L21

vb
Me.pivotGrid.DataSource = GetDataTable()
    Me.pivotGrid.BestFit()
End Sub

See Also

BestFitMode

BestFitColumn(Int32)

BestFitRow(Int32)

PivotGridControl Class

PivotGridControl Members

DevExpress.Xpf.PivotGrid Namespace