Version

ColumnResizing Event

Event raised when a user initiated column resizing is begun.
Syntax
'Declaration
 
Public Event ColumnResizing As EventHandler(Of CancellableColumnResizingEventArgs)
Event Data

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.

PropertyDescription
Cancel (Inherited from Infragistics.CancellableEventArgs) 
Columns A Collection of columns that will be resized during this resizing action.
Width The starting width of the column.
Example
This sample demonstrates how to handle the ColumnResizing event which is fired right before a column is resized.

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

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");
}
<ig:XamGrid x:Name="MyGrid" 
   
ColumnResizing="MyGrid_ColumnResizing" >
</ig:XamGrid>
Requirements

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

See Also