Back to Devexpress

GridView.ColumnWidthChanged Event

windowsforms-devexpress-dot-xtragrid-dot-views-dot-grid-dot-gridview-3d347d62.md

latest4.5 KB
Original Source

GridView.ColumnWidthChanged Event

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

Declaration

csharp
[DXCategory("Property Changed")]
public event ColumnEventHandler ColumnWidthChanged
vb
<DXCategory("Property Changed")>
Public Event ColumnWidthChanged As ColumnEventHandler

Event Data

The ColumnWidthChanged event's data class is ColumnEventArgs. The following properties provide information specific to this event:

PropertyDescription
ColumnGets the column being processed.

Remarks

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.

  • C#

  • VB.NET

csharp
private void gridView1_ColumnWidthChanged(object sender, DevExpress.XtraGrid.Views.Base.ColumnEventArgs e) {
    e.Column.Width = Math.Min(e.Column.Width, colAddress.Width);
}
vb
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:

The 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

csharp
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

vb
AddHandler gridView1.RowCountChanged, AddressOf OnGridViewRowCountChanged
AddHandler gridView1.ColumnWidthChanged, AddressOf OnGridViewColumnWidthChanged
AddHandler gridView1.DragObjectDrop, AddressOf OnGridViewDragObjectDrop

See Also

Resize(Int32)

Width

ColumnAutoWidth

GridView Class

GridView Members

DevExpress.XtraGrid.Views.Grid Namespace