Version

AfterColPosChanged Event

Occurs after a column has been moved, sized or swapped.
Syntax
'Declaration
 
Public Event AfterColPosChanged As AfterColPosChangedEventHandler
public event AfterColPosChangedEventHandler AfterColPosChanged
Event Data

The event handler receives an argument of type AfterColPosChangedEventArgs containing data related to this event. The following AfterColPosChangedEventArgs properties provide information specific to this event.

PropertyDescription
ColumnHeaders columns (read-only)
ColumnPosChangedType column position changed type (read-only)
Remarks

The action argument indicates which action occurred to the column or columns: moving, swapping, or sizing.

The columns argument returns a reference to a SelectedCols collection that can be used to retrieve references to the UltraGridColumn object or objects that were moved, swapped, or sized. You can use this reference to access any of the returned collection's properties or methods, as well as the properties or methods of the objects within the collection.

This event is generated after one or more columns are moved, swapped, or sized, either programmatically, or by user interaction. A column can be sized programmatically by setting its Width property and can be moved programmatically by setting its header's VisiblePosition property.

The VisiblePosition property of a column's header can be used to determine the new position of a column that was moved or swapped.

To prevent the user from attempting to move, swap, or size a column, set the AllowColMoving, AllowColSwapping, or AllowColSizing properties, respectively.

The AfterGroupPosChanged event is generated after one or more groups are moved, swapped, or sized.

The BeforeColPosChanged event, which occurs before one or more columns are moved, swapped, or sized, is generated before this event.

Example
Following code shows some of the information available in AfterColPosChanged event.

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.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid
Imports System.Diagnostics

   Private Sub UltraGrid1_AfterColPosChanged(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.AfterColPosChangedEventArgs) Handles ultraGrid1.AfterColPosChanged

       ' AfterColPosChanged gets fired after the user has moved, swapped or resized a column
       ' or columns.

       If PosChanged.Moved = e.PosChanged Then
           ' One or more columns have been moved

           Debug.WriteLine("Following are the new positions of the columns:")

           Dim i As Integer
           For i = 0 To e.ColumnHeaders.Length - 1
               Debug.WriteLine("    " & e.ColumnHeaders(i).Column.Key & " is moved to the new visible index of " & e.ColumnHeaders(i).VisiblePosition)
           Next
       ElseIf PosChanged.Swapped = e.PosChanged Then
           ' Two columns have been swapped.
           Debug.WriteLine(e.ColumnHeaders(0).Column.Key & " and " & e.ColumnHeaders(1).Column.Key & " columns have been swapped.")
       ElseIf PosChanged.Sized = e.PosChanged Then
           ' A column has been resized.
           Debug.WriteLine(e.ColumnHeaders(0).Column.Key & " has been resized to the new width of " & e.ColumnHeaders(0).Column.Width)
       End If

   End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;

private void ultraGrid1_AfterColPosChanged(object sender, Infragistics.Win.UltraWinGrid.AfterColPosChangedEventArgs e)
{

	// AfterColPosChanged gets fired after the user has moved, swapped or resized a column
	// or columns.
	
	if ( PosChanged.Moved == e.PosChanged )
	{	
		// One or more columns have been moved

		Debug.WriteLine( "Following are the new positions of the columns:" );

		for ( int i = 0; i < e.ColumnHeaders.Length; i++ )
		{										
			Debug.WriteLine( "    " + e.ColumnHeaders[i].Column.Key + 
				" is moved to the new visible index of " + e.ColumnHeaders[i].VisiblePosition );
		}
	}
	else if ( PosChanged.Swapped == e.PosChanged )
	{
		// Two columns have been swapped.

		Debug.WriteLine( e.ColumnHeaders[0].Column.Key + " and " + e.ColumnHeaders[1].Column.Key 
			+ " columns have been swapped." );				
	}
	else if ( PosChanged.Sized == e.PosChanged )
	{
		// A column has been resized.

		Debug.WriteLine( e.ColumnHeaders[0].Column.Key + 
			" has been resized to the new width of " + e.ColumnHeaders[0].Column.Width );
	}

}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, 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