Skip to main content

TcxCustomGridTableView.ApplyBestFit(TcxCustomGridTableItem,Boolean,Boolean) Method

Adjusts the width of the View’s items to display their content in full.

Declaration

procedure ApplyBestFit(AItem: TcxCustomGridTableItem = nil; ACheckSizingAbility: Boolean = False; AFireEvents: Boolean = False); virtual;

Parameters

Name Type Description
AItem TcxCustomGridTableItem

The target View item. If nil (in Delphi) or nullptr (in C++Builder), the procedure adjusts the width of all visible items in the View.

ACheckSizingAbility Boolean

If True, the procedure checks if an item can change its width. If False, the procedure adjusts an item’s width even if restrictive options are set (that is, if the item’s Options.HorzSizing property and the View’s OptionsCustomize.ColumnHorzSizing property are set to False).

AFireEvents Boolean

True to raise the OnColumnSizeChanged event if View items change their width; otherwise, False.

Remarks

The ApplyBestFit procedure iterates through all data records and calculates the maximum width of item cells. You can use the OptionsBehavior.BestFitMaxRecordCount property to limit the number of processed records and improve performance. Use an item’s BestFitMaxWidth property to set the item’s maximum width constraint to maintain the grid View layout.

Note

Call the ApplyBestFit procedure only if the View is visible.

A user can double-click the right edge of an item to display its content in full. To prevent a user from changing the item’s width, set the item’s Options.HorzSizing property or the View’s OptionsCustomize.ColumnHorzSizing property to False.

See Also