TreeList.BestFitColumns() Method

Modifies the width of each visible column so that the contents of its cells are not truncated, if possible.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v20.1.dll


public virtual void BestFitColumns()
Public Overridable Sub BestFitColumns


Call the BestFitColumns method to resize the columns so that they completely display their contents. Note that columns are resized to the minimum width required. If the TreeListOptionsView.AutoWidth option is enabled, columns change their width with respect to the contents of their cells, but the total width of all columns remains equal to the control's width. So, cell values may appear truncated after a call to the BestFitColumns method in such circumstances. There can also be situations when columns are wider than required to accommodate the contents of their cells.

If the TreeListOptionsView.AutoWidth option is disabled, columns get the width required to display their cell values without truncating them.

The TreeListOptionsView.BestFitNodes property specifies which nodes are taken into account when searching for the widest column cell.

Note: the BestFitColumns method changes the width of all columns, including the columns whose TreeListOptionsColumn.AllowSize option is disabled.

The image below displays the effect of the BestFitColumns method call.

Columns - BestFitColumns

If you want to display specific column cells without truncating their values, use the TreeListColumn.BestFit method of the desired column.


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