Skip to main content

RepositoryItemLookUpEdit.BestFit() Method

Changes the widths of columns in the dropdown, to best fit their contents.

Namespace: DevExpress.XtraEditors.Repository

Assembly: DevExpress.XtraEditors.v24.2.dll

Declaration

public virtual int BestFit()

Returns

Type Description
Int32

The adjusted total width of the columns in the dropdown.

Remarks

This method proportionally resizes the columns in the dropdown according to their contents. If there are no columns in the RepositoryItemLookUpEdit.Columns collection, the BestFit method does nothing.

The BestFit method is automatically called by the RepositoryItemLookUpEdit.PopulateColumns method, even if the RepositoryItemLookUpEditBase.BestFitMode option is set to BestFitMode.None.

If there are columns in the RepositoryItemLookUpEdit.Columns collection, the “best-fit” functionality is not automatically invoked. In this instance, you may call the BestFit method manually, if required.

To invoke the “best-fit” functionality for the columns and resize the dropdown window to fit all the columns, set the RepositoryItemLookUpEditBase.BestFitMode property to BestFitMode.BestFitResizePopup. The BestFit method will be automatically called when opening the dropdown for the first time.

The “best-fit” functionality processes rows in the dropdown to calculate the optimal widths for the columns. By default, all the rows are processed. Limiting the number of the rows allows you to improve the “best-fit” performance for large data sets. This can be accomplished via the RepositoryItemLookUpEdit.BestFitRowCount property.

See Also