Returns or sets a value that determines how the ListItem objects in a ListView control are sorted.
Syntax
object.SortKey [= integer]
The SortKey property syntax has these parts:
Part | Description |
object | An object expression that evaluates to a ListView control. |
integer | An integer specifying the sort key, as described in Settings. |
Settings
The settings for integer are:
Setting | Description |
0 | Sort using the ListItem object's Text property. |
> 1 | Sort using the subitem whose collection index is specified here. |
Remarks
The Sorted property must be set to True before the change takes place.
It is common to sort a list when the column header is clicked. For this reason, the SortKey property is commonly included in the ColumnClick event to sort the list using the clicked column, as determined by the sort key, and demonstrated in the following example:
Private Sub ListView1_ColumnClick (ByVal ColumnHeader as ColumnHeader)
ListView1.SortKey=ColumnHeader.Index-1
End Sub