Skip to main content

GridOptionsView.ColumnAutoWidth Property

Gets or sets a value that specifies columns automatically adjust their width to fit the grid’s width.

Namespace: DevExpress.XtraGrid.Views.Grid

Assembly: DevExpress.XtraGrid.v24.2.dll

Declaration

[DefaultValue(true)]
[XtraSerializableProperty]
public virtual bool ColumnAutoWidth { get; set; }

Property Value

Type Default Description
Boolean true

true to enable the column auto-width feature; otherwise, false.

Property Paths

You can access this nested property as listed below:

Object Type Path to ColumnAutoWidth
GridView
.OptionsView .ColumnAutoWidth

Remarks

The following example handles the check edit’s CheckedChanged event to enable/disable automatic column width calculation:

void checkEdit1_CheckedChanged(object sender, EventArgs e) {
    gridView1.OptionsView.ColumnAutoWidth = checkEdit1.Checked;
    if (!checkEdit1.Checked)
        gridView1.BestFitColumns();
}

The following animation shows the result:

Enable Horizontal Scrolling - WinForms Data Grid, DevExpress

Note

If the column’s OptionsColumn.FixedWidth option is enabled, the column’s width is not changed when applying the auto width feature.

Read the following topic for additional information about grid columns: Data Grid Columns.

The following code snippets (auto-collected from DevExpress Examples) contain references to the ColumnAutoWidth property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also