共用方式為


CMFCHeaderCtrl::SetSortColumn

Sets the sort order of a specified column in a header control.

void SetSortColumn(
   int iColumn,
   BOOL bAscending=TRUE,
   BOOL bAdd=FALSE 
);

Parameters

  • [in] iColumn
    The zero-based index of a header control column. If this parameter is less than zero, this method removes all columns from the list of sort columns.

  • [in] bAscending
    Specifies the sort order of the column that the iColumn parameter specifies. TRUE to set ascending order; FALSE to set descending order. The default value is TRUE.

  • [in] bAdd
    TRUE to set the sort order of the column that the iColumn parameter specifies.

    If the current header control is in multiple column sort mode, this method adds the specified column to the list of sort columns. Use CMFCHeaderCtrl::EnableMultipleSort to set multiple column sort mode.

    If multiple column sort mode is not set and this method is compiled in debug mode, this method asserts. If multiple column sort mode is not set and this method is compiled in retail mode, this method first removes all columns from the list of sort columns, and then adds the specified column to the list.

    FALSE to first remove all columns from the list of sort columns, and then add the specified column to the list. The default value is FALSE.

Remarks

Use this method to set the sort order of a column. If necessary, this method adds the column to the list of sort columns. The header control uses the sort order to draw a sort arrow that points up or down.

Requirements

Header: afxheaderctrl.h

See Also

Reference

CMFCHeaderCtrl Class

Hierarchy Chart

CMFCHeaderCtrl::EnableMultipleSort