Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid
    Private Sub UltraGrid1_BeforeRowLayoutItemResized(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.BeforeRowLayoutItemResizedEventArgs) Handles UltraGrid1.BeforeRowLayoutItemResized
        Debug.Write("BeforeRowLayoutItemResized: ")
        If TypeOf e.RowLayoutItem Is UltraGridColumn Then
            ' If the RowLayoutItem is an instance of UltraGridColumn, then cells associated
            ' with that column are being resized.
            Dim column As UltraGridColumn = DirectCast(e.RowLayoutItem, UltraGridColumn)
            Debug.Write("Cell in row-layout resized. Column = " & column.Header.Caption)
        Else
            ' If the RowLayoutItem is an instance of HeaderBase, then column header (also 
            ' referred to as column label) is being resized.
            Dim header As HeaderBase = DirectCast(e.RowLayoutItem, HeaderBase)
            Debug.Write("Header in row-layout resized. Header = " & header.Caption)
        End If
        Debug.WriteLine(" Old Size = " & e.OldSize.ToString() & " New Size = " & e.NewSize.ToString())
        ' You can conditionally cancel the resize operation by setting Cancel to true.
        If e.OldSize.Height <> e.NewSize.Height Then
            e.Cancel = True
        ElseIf (e.NewSize.Width > 200) Then
            ' You can also set the NewSize to impose constraints on how the item can be resized.
            ' In this case we will prevent the user from resizing items greater than 200.
            e.NewSize = New Size(200, e.NewSize.Height)
        End If
    End Sub
    Private Sub UltraGrid1_AfterRowLayoutItemResized(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.AfterRowLayoutItemResizedEventArgs) Handles UltraGrid1.AfterRowLayoutItemResized
        Debug.Write("AfterRowLayoutItemResized: ")
        If TypeOf e.RowLayoutItem Is UltraGridColumn Then
            ' If the RowLayoutItem is an instance of UltraGridColumn, then cells associated
            ' with that column are being resized.
            Dim column As UltraGridColumn = DirectCast(e.RowLayoutItem, UltraGridColumn)
            Debug.Write("Cell in row-layout resized. Column = " & column.Header.Caption)
        Else
            ' If the RowLayoutItem is an instance of HeaderBase, then column header (also 
            ' referred to as column label) is being resized.
            Dim header As HeaderBase = DirectCast(e.RowLayoutItem, HeaderBase)
            Debug.Write("Header in row-layout resized. Header = " & header.Caption)
        End If
        Debug.WriteLine(" New Size = " & e.RowLayoutItem.PreferredSize.ToString())
    End Sub