'Declaration Public Event ColumnResizing As EventHandler(Of CancellableColumnResizingEventArgs)
public event EventHandler<CancellableColumnResizingEventArgs> ColumnResizing
The event handler receives an argument of type CancellableColumnResizingEventArgs containing data related to this event. The following CancellableColumnResizingEventArgs properties provide information specific to this event.
AddHandler Me.MyGrid.ColumnResizing, AddressOf MyGrid_ColumnResizing Private Sub MyGrid_ColumnResizing(ByVal sender As System.Object, ByVal e As CancellableColumnResizingEventArgs) Dim productNameColumn As Column = Me.MyGrid.Columns.DataColumns("ProductName") ' If the column being resized is Product Name, cancel the event If (e.Columns.Contains(productNameColumn)) Then System.Diagnostics.Debug.WriteLine("ProductName column cannot be resized") e.Cancel = True Return End If System.Diagnostics.Debug.WriteLine("Column is resizing") End Sub
this.MyGrid.ColumnResizing += new EventHandler<CancellableColumnResizingEventArgs>(MyGrid_ColumnResizing); void MyGrid_ColumnResizing(object sender, CancellableColumnResizingEventArgs e) { Column productNameColumn = this.MyGrid.Columns.DataColumns["ProductName"]; // If the column being resized is Product Name, cancel the event if (e.Columns.Contains(productNameColumn)) { System.Diagnostics.Debug.WriteLine("ProductName column cannot be resized"); e.Cancel = true; return; } System.Diagnostics.Debug.WriteLine("Column is resizing"); }
Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2