'宣言 Public Event ColumnResizing As EventHandler(Of CancellableColumnResizingEventArgs)
public event EventHandler<CancellableColumnResizingEventArgs> ColumnResizing
イベント ハンドラが、このイベントに関連するデータを含む、CancellableColumnResizingEventArgs 型の引数を受け取りました。次の CancellableColumnResizingEventArgs プロパティには、このイベントの固有の情報が記載されます。
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"); }