Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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

NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation

#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:

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