ListView_SetSortColumn()

Examples


The ListView_SetSortColumn() function specifies the column by which a list view field is sorted.

Syntax

ListView_SetSortColumn(list_view_field, column_index, sort_order {, refresh)

Parameters

list_view_field – The list view field for which sorting is being specified.

column_index – An integer specifying the column to sort. The value 1 indicates the first column that was added to the list view.

Dragging a column to a different position in the list view does not affect the column index.


sort_order – An integer corresponding to one of the following constants:

[spacer]

Constant

Description

LV_SORT_ASCENDING

The column will be sorted in ascending order.

LV_SORT_DESCENDING

The column will be sorted in descending order.


refresh – An optional boolean. If set to true, the list view field is re-sorted immediately. If set to false, the list view field must be updated manually using the ListView_Sort() function.

Return value

An integer containing the column index of the column by which the list was previously sorted.

Comments

For the ListView_SetSortColumn() function to work properly, the SortMethod property for the list view field must be set to Column.

A list view can be sorted by only one column at a time.


Documentation Feedback