Occurs when the user clicks a column header within the list view control.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
The event occurs when the user clicks one of the column headers in a details view of the items in a ListView control (when the View property is set to Details). The event is typically handled to sort the items in the ListView using the clicked column as the column to sort by.
For more information about handling events, see Handling and Raising Events.
The following code example creates a form that contains a ListView control that manually sorts items when a column in the ListView control is clicked. The example defines a class called ListViewItemComparer that implements the System.Collections.IComparer interface that performs the ListViewItem comparison. The example creates an instance of ListViewItemComparer and uses it to set the ListViewItemSorter property of the ListView control. The Sort method call in the event handler uses the methods defined in ListViewItemComparer to perform the sort of items, based on the column that is clicked.