Version

ColumnSorting Event

Occurs before a column is sorted by the end user.
Syntax
'Declaration
 
Public Event ColumnSorting As ColumnSortingEventHandler
public event ColumnSortingEventHandler ColumnSorting
Event Data

The event handler receives an argument of type ColumnSortingEventArgs containing data related to this event. The following ColumnSortingEventArgs 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.
NewValue Gets/sets the new value for the associated CancelableColumnEventArgs.Column instance's Sorting property.
Example
The following code sample demonstrates how to handle the UltraListView's ColumnSorting and ColumnSorted 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.

Imports Infragistics.Win
Imports Infragistics.Win.UltraWinListView


    Private Sub ultraListView1_ColumnSorting(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinListView.ColumnSortingEventArgs) Handles ultraListView1.ColumnSorting
        '	If the column's DataType is integer, disallow the sort.
        If e.Column.DataType Is GetType(Integer) Then
            e.Cancel = True
        Else
            '	If the new value is 'None', change it to 'Ascending'.
            If (e.NewValue = Sorting.None) Then e.NewValue = Sorting.Ascending
        End If

    End Sub

    Private Sub ultraListView1_ColumnSorted(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinListView.ColumnSortedEventArgs) Handles ultraListView1.ColumnSorted
        Me.lblSortStatus.Text = e.Column.TextResolved
    End Sub
using Infragistics.Win;
using Infragistics.Win.UltraWinListView;
using System.Diagnostics;


		private void ultraListView1_ColumnSorting(object sender, Infragistics.Win.UltraWinListView.ColumnSortingEventArgs e)
		{
			//	If the column's DataType is integer, disallow the sort.
			if ( e.Column.DataType == typeof(int) )
				e.Cancel = true;
			else
			{
				//	If the new value is 'None', change it to 'Ascending'.
				if ( e.NewValue == Sorting.None )
					e.NewValue = Sorting.Ascending;
			}
		}

		private void ultraListView1_ColumnSorted(object sender, Infragistics.Win.UltraWinListView.ColumnSortedEventArgs e)
		{
			this.lblSortStatus.Text = e.Column.TextResolved;
		}
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