TreeList.BestFitColumns(Boolean) Method

Modifies the width of each visible column so that the contents of its cells are not truncated, if possible. Allows you to resize columns to fit the treelist width.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v20.1.dll


public virtual void BestFitColumns(
    bool applyAutoWidth
Public Overridable Sub BestFitColumns(
    applyAutoWidth As Boolean


Name Type Description
applyAutoWidth Boolean

true if the total width of columns must be equal to the control's width after resizing; otherwise false.


Call the BestFitColumns method to resize columns to the minimum width to display their contents without trimming, if possible.

The applyAutoWidth parameter is in effect if the TreeListOptionsView.AutoWidth option is disabled. Otherwise, the BestFitColumns method performs column resizing as if the applyAutoWidth parameter were set to true.

Columns - BestFitAutoWidth

Use the TreeListOptionsView.BestFitNodes property to specify which nodes take part in calculating the largest column cell.


All columns are resized when the BestFitColumns method is called even if the TreeListOptionsColumn.AllowSize option of columns is disabled.

To apply the "best fit" functionality to a certain column, use the TreeListColumn.BestFit method.


If the TreeList control is created at design time, changing the visual settings and size of the control and its elements (e.g., invoking the best fit functionality) is not in effect before the Tree List has completed its initialization. To customize these settings in the form's System.Windows.Forms.Form.Load event handler, call the TreeList.ForceInitialize method prior to performing additional customization.

See Also