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

Used to specify what type of position change has occurred

Syntax

Visual Basic (Declaration) 
Public Enum PosChanged 
   Inherits System.Enum
C# 
public enum PosChanged : System.Enum 

Members

MemberDescription
HiddenStateChanged Hidden state of the column changed. This is fired when the end user changes the hidden state of a column, for example via the ColumnChooser functionality.
Moved Position Moved. The object's position changed because it was moved
Sized Position Sized. The object's position changed because it was resized
Swapped Position Swapped. The object's position changed because it was swapped

Example

Following code shows some of the information available in BeforeColPosChanged 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.

Visual BasicCopy Code
Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid
Imports System.Diagnostics

   Private Sub UltraGrid1_BeforeColPosChanged(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.BeforeColPosChangedEventArgs) Handles ultraGrid1.BeforeColPosChanged

       ' BeforeColPosChanged gets fired when the user moves, swaps or resizes a column
       ' or columns. This event gives a chance to cancel the user action.

       If PosChanged.Moved = e.PosChanged Then

           ' One or more columns are being moved

           Dim columnList As String = ""

           Dim i As Integer
           For i = 0 To e.ColumnHeaders.Length - 1
               If i > 0 Then columnList = columnList & ", "

               columnList = columnList + e.ColumnHeaders(i).Column.Key
           Next

           Dim result As DialogResult = MessageBox.Show( _
               "You are about to move " & columnList & " columns. Do you want to continue ?", _
               "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question)

           If DialogResult.No = result Then
               ' Cancel the move by setting Cancel off the event args.
               e.Cancel = True
           End If

       ElseIf PosChanged.Swapped = e.PosChanged Then

           ' Two columns are being swapped.

           Dim result As DialogResult = MessageBox.Show( _
               "You are about to swap " & e.ColumnHeaders(0).Column.Key & " with " _
               + e.ColumnHeaders(1).Column.Key & " Do you want to continue ?", _
               "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question)

           If DialogResult.No = result Then
               ' Cancel the move by setting Cancel off the event args.
               e.Cancel = True
           End If

       ElseIf PosChanged.Sized = e.PosChanged Then

           ' A column is bieng resized.

           ' When a column is being resized, e.ColumnHeaders contains the column header that's
           ' being resized.
           Debug.WriteLine("User is about to resize " & e.ColumnHeaders(0).Column.Key & " colun.")

       End If

   End Sub
C#Copy Code
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;

private void ultraGrid1_BeforeColPosChanged(object sender, Infragistics.Win.UltraWinGrid.BeforeColPosChangedEventArgs e)
{

	// BeforeColPosChanged gets fired when the user moves, swaps or resizes a column
	// or columns. This event gives a chance to cancel the user action.

	if ( PosChanged.Moved == e.PosChanged )
	{
		// One or more columns are being moved

		string columnList = "";
		
		for ( int i = 0; i < e.ColumnHeaders.Length; i++ )
		{
			if ( i > 0 )
				columnList = columnList + ", ";

			columnList = columnList + e.ColumnHeaders[i].Column.Key;
		}

		DialogResult result = MessageBox.Show( 
			"You are about to move " + columnList + " columns. Do you want to continue ?",
			"Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question );

		if ( DialogResult.No == result )
		{
			// Cancel the move by setting Cancel off the event args.
			e.Cancel = true;
		}
	}
	else if ( PosChanged.Swapped == e.PosChanged )
	{
		// Two columns are being swapped.

		DialogResult result = MessageBox.Show( 
			"You are about to swap " + e.ColumnHeaders[0].Column.Key + " with " 
					+ e.ColumnHeaders[1].Column.Key + " Do you want to continue ?", 
			"Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question );

		if ( DialogResult.No == result )
		{
			// Cancel the move by setting Cancel off the event args.
			e.Cancel = true;
		}
	}
	else if ( PosChanged.Sized == e.PosChanged )
	{
		// A column is bieng resized.

		// When a column is being resized, e.ColumnHeaders contains the column header that's
		// being resized.
		Debug.WriteLine( "User is about to resize " + e.ColumnHeaders[0].Column.Key + " colun." );
	}

}

See Also