Skip to main content
A newer version of this page is available. .

TableView.BestFitColumns() Method

Resizes all visible columns to optimally fit their contents.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v18.2.dll

Declaration

public void BestFitColumns()

Remarks

Call the BestFitColumns method to resize the columns so that they display their contents completely. Note that columns are resized to the minimum width required. The content taken into account when calculating the required column width includes the column header contents, data cell contents and the footer summary cell’s content. If the View’s TableView.BestFitMaxRowCount property value is -1, all data cells are processed. Otherwise, the View only processes the number of cells specified by that property value.

If a column’s BaseColumn.FixedWidth option is enabled, the column is not resized when calling the BestFitColumns method.

To apply the best width feature to a particular column, call the column’s TableView.BestFitColumn method.

Note

The BestFitColumns method should only be called when the grid is loaded.

Refer to the Best Fit topic to learn more.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the BestFitColumns() 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.

See Also