Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TreeListView.BestFitColumns() Method

In This Article

Resizes all visible columns to optimally fit their contents.

Namespace: DevExpress.Xpf.Grid

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

NuGet Package: DevExpress.Wpf.Grid.Core

#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 TreeList’s TreeListView.BestFitMaxRowCount property value is -1, all data cells are processed. Otherwise, the TreeList 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 TreeListView.BestFitColumn method.

Note

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

Refer to the Best Fit topic to learn more.

See Also