windowsforms-devexpress-dot-xtragrid-dot-views-dot-grid-dot-gridview-3d347d62.md
Occurs after a column’s width has been changed.
Namespace : DevExpress.XtraGrid.Views.Grid
Assembly : DevExpress.XtraGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation
[DXCategory("Property Changed")]
public event ColumnEventHandler ColumnWidthChanged
<DXCategory("Property Changed")>
Public Event ColumnWidthChanged As ColumnEventHandler
The ColumnWidthChanged event's data class is ColumnEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Column | Gets the column being processed. |
This event occurs in the following cases:
an end-user has dragged a column’s right edge, and thus modified its width;
a column’s width has been modified via the GridColumn.Resize method.
private void gridView1_ColumnWidthChanged(object sender, DevExpress.XtraGrid.Views.Base.ColumnEventArgs e) {
e.Column.Width = Math.Min(e.Column.Width, colAddress.Width);
}
Private Sub gridView1_ColumnWidthChanged(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Base.ColumnEventArgs) _
Handles gridView1.ColumnWidthChanged
e.Column.Width = Math.Min(e.Column.Width, colAddress.Width)
End Sub
The ColumnWidthChanged event isn’t fired when a column’s width is changed via the GridColumn.Width property.
This event also isn’t fired when the following conditions are met:
trueThe following code snippet (auto-collected from DevExpress Examples) contains a reference to the ColumnWidthChanged event.
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.
winforms-grid-change-height-to-match-height-of-rows/CS/GridControlAutoSize/Form1.cs#L53
gridView1.RowCountChanged += new EventHandler(OnGridViewRowCountChanged);
gridView1.ColumnWidthChanged += new ColumnEventHandler(OnGridViewColumnWidthChanged);
gridView1.DragObjectDrop += new DragObjectDropEventHandler(OnGridViewDragObjectDrop);
winforms-grid-change-height-to-match-height-of-rows/VB/GridControlAutoSize/Form1.vb#L55
AddHandler gridView1.RowCountChanged, AddressOf OnGridViewRowCountChanged
AddHandler gridView1.ColumnWidthChanged, AddressOf OnGridViewColumnWidthChanged
AddHandler gridView1.DragObjectDrop, AddressOf OnGridViewDragObjectDrop
See Also