Infragistics(R) NetAdvantage(R) Windows Forms
BeforeRowLayoutItemResizedEventHandler Delegate
See Also  Example E-mail your feedback on this topic.
Infragistics.Win.UltraWinGrid Namespace : BeforeRowLayoutItemResizedEventHandler Delegate

sender
e
Delegate for BeforeRowLayoutItemResized event.

Syntax

Visual Basic (Declaration) 
Public Delegate Sub BeforeRowLayoutItemResizedEventHandler( _
   ByVal sender As Object, _
   ByVal e As BeforeRowLayoutItemResizedEventArgs _
) 
C# 
public delegate void BeforeRowLayoutItemResizedEventHandler( 
   object sender,
   BeforeRowLayoutItemResizedEventArgs e
)

Parameters

sender
e

Example

Following code shows some of the information available in BeforeRowLayoutItemResized and AfterRowLayoutItemResized events.

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.

Visual BasicCopy Code
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
C#Copy Code
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;

		private void ultraGrid1_BeforeRowLayoutItemResized(object sender, Infragistics.Win.UltraWinGrid.BeforeRowLayoutItemResizedEventArgs e)
		{
			Debug.Write( "BeforeRowLayoutItemResized: " );

			if ( e.RowLayoutItem is UltraGridColumn )
			{
				// If the RowLayoutItem is an instance of UltraGridColumn, then cells associated
				// with that column are being resized.
				UltraGridColumn column = (UltraGridColumn)e.RowLayoutItem;

				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.
				HeaderBase header = (HeaderBase)e.RowLayoutItem;

				Debug.Write( "Header in row-layout resized. Header = " + header.Caption );
			}

			Debug.WriteLine( " Old Size = " + e.OldSize.ToString( ) + " New Size = " + e.NewSize );

			// You can conditionally cancel the resize operation by setting Cancel to true.
			if ( e.OldSize.Height != e.NewSize.Height )
			{
				e.Cancel = true;
			}
			// 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.
			else if ( e.NewSize.Width > 200 )
			{
				e.NewSize = new Size( 200, e.NewSize.Height );
			}
		}

		private void ultraGrid1_AfterRowLayoutItemResized(object sender, Infragistics.Win.UltraWinGrid.AfterRowLayoutItemResizedEventArgs e)
		{
			Debug.Write( "AfterRowLayoutItemResized: " );

			if ( e.RowLayoutItem is UltraGridColumn )
			{
				// If the RowLayoutItem is an instance of UltraGridColumn, then cells associated
				// with that column are being resized.
				UltraGridColumn column = (UltraGridColumn)e.RowLayoutItem;

				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.
				HeaderBase header = (HeaderBase)e.RowLayoutItem;

				Debug.Write( "Header in row-layout resized. Header = " + header.Caption );
			}

			Debug.WriteLine( " New Size = " + e.RowLayoutItem.PreferredSize.ToString( ) );
		}

See Also