Version

ColumnMoving Event

Occurs before a column header is moved by the end user.
Syntax
'Declaration
 
Public Event ColumnMoving As ColumnMovingEventHandler
public event ColumnMovingEventHandler ColumnMoving
Event Data

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

PropertyDescription
Cancel (Inherited from System.ComponentModel.CancelEventArgs) 
Column (Inherited from Infragistics.Win.UltraWinListView.CancelableColumnEventArgs)Returns the UltraListViewColumnBase with which this instance is associated.
Example
The following code sample demonstrates how the UltraListView's ColumnMoving and ColumnMoved events can be handled to conditionally prevent a column from being moved, and change the visible position of a column:

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.Win
Imports Infragistics.Win.UltraWinListView


    Private Sub ultraListView1_ColumnMoving(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinListView.ColumnMovingEventArgs) Handles ultraListView1.ColumnMoving
        '	If the column about to be moved is the MainColumn, cancel
        '	the event to prevent the column from being moved.
        If e.Column.GetType() Is GetType(UltraListViewMainColumn) Then e.Cancel = True
    End Sub

    Private Sub ultraListView1_ColumnMoved(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinListView.ColumnMovedEventArgs) Handles ultraListView1.ColumnMoved
        Dim listView As UltraListView = CType(sender, UltraListView)

        '	If an UltraListViewSubItemColumn was moved to the leftmost
        '	visible position, move the MainColumn into the leftmost
        '	position instead, and move the column that was moved by
        '	the end user to the next position after that.
        If e.Column.GetType() Is GetType(UltraListViewSubItemColumn) AndAlso _
          e.Column.VisiblePositionInDetailsView = 0 Then

            listView.MainColumn.VisiblePositionInDetailsView = 0
            e.Column.VisiblePositionInDetailsView = 1
        End If
    End Sub
using Infragistics.Win;
using Infragistics.Win.UltraWinListView;
using System.Diagnostics;


		private void ultraListView1_ColumnMoving(object sender, Infragistics.Win.UltraWinListView.ColumnMovingEventArgs e)
		{
			//	If the column about to be moved is the MainColumn, cancel
			//	the event to prevent the column from being moved.
			if ( e.Column is UltraListViewMainColumn )
				e.Cancel = true;
		}
	
		private void ultraListView1_ColumnMoved(object sender, Infragistics.Win.UltraWinListView.ColumnMovedEventArgs e)
		{
			UltraListView listView = sender as UltraListView;

			//	If an UltraListViewSubItemColumn was moved to the leftmost
			//	visible position, move the MainColumn into the leftmost
			//	position instead, and move the column that was moved by
			//	the end user to the next position after that.
			if ( e.Column is UltraListViewSubItemColumn &&
				 e.Column.VisiblePositionInDetailsView == 0 )
			{
				listView.MainColumn.VisiblePositionInDetailsView = 0;
				e.Column.VisiblePositionInDetailsView = 1;
			}
		}
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