wpf-devexpress-dot-xpf-dot-pivotgrid-dot-pivotgridcontrol-e0487b2b.md
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
public void BestFit()
Public Sub BestFit
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:
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.
pivotGridControl1.BestFitArea = DevExpress.Xpf.PivotGrid.FieldBestFitArea.FieldHeader;
pivotGridControl1.BestFit();
}
wpf-pivotgrid-customize-the-cell-template/CS/HowToCustomizeCellTemplate/MainWindow.xaml.cs#L20
pivotGridControl1.BestFitArea = DevExpress.Xpf.PivotGrid.FieldBestFitArea.FieldHeader;
pivotGridControl1.BestFit();
}
pivotGridControl1.DataSource = OrderSourceList;
pivotGridControl1.BestFit();
}
wpf-pivot-grid-implement-custom-summary/CS/DXPivotGrid_CustomSummary/MainWindow.xaml.cs#L30
{
pivotGridControl1.BestFit();
}
wpf-pivot-grid-split-field-value-cells/CS/Window1.xaml.cs#L18
pivotGrid.DataSource = PivotHelper.GetDataTable();
pivotGrid.BestFit();
}
Me.pivotGridControl1.BestFitArea = FieldBestFitArea.FieldHeader
Me.pivotGridControl1.BestFit()
End Sub
wpf-pivotgrid-customize-the-cell-template/VB/HowToCustomizeCellTemplate/MainWindow.xaml.vb#L21
pivotGridControl1.BestFitArea = DevExpress.Xpf.PivotGrid.FieldBestFitArea.FieldHeader
pivotGridControl1.BestFit()
End Sub
pivotGridControl1.DataSource = OrderSourceList
pivotGridControl1.BestFit()
End Sub
wpf-pivot-grid-implement-custom-summary/VB/DXPivotGrid_CustomSummary/MainWindow.xaml.vb#L29
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
Me.pivotGrid.DataSource = GetDataTable()
Me.pivotGrid.BestFit()
End Sub
See Also