|Visual Basic (Usage)||Copy Code|
- Index of column to set
|Visual Basic||Copy Code|
This method automatically sorts the rows in a sheet according to the specified column in ascending order unless the sheet was previously automatically sorted ascending. This also shows the sort indicator unless the sort indicator for the column has been disabled with a call to the SetColumnShowSortIndicator method or the Column.ShowSortIndicator property. The SetColumnShowSortIndicator method must be called before the AutoSortColumn method. Otherwise, the sort indicator is shown and remains displayed.
This method performs the same action as clicking in the column header of the specified column that has its SetColumnAllowAutoSort property set to true. (The SetColumnAllowAutoSort property does not need to be set to true to use this method.) . If this method is called successively with the same column index, then the direction of the sort is reversed. If the method is called with a different column index, then the previously sorted column's sort indicator is changed back to SortIndicator.None (if there is one) and the specified column is used as the key column in a call to SortRows to sort all the rows in the sheet by that column.
This does not affect the data model, only how the data is displayed. Different overloads provide different ways to sort the rows in a sheet.
This method calls the SortRows method, which turns on the sort indicator for the key column specified and only in the overloads that take the showIndicator argument. SortRows does not change the sort indicator back again on successive calls. This must be done manually by the developer with the SheetView.SetColumnShowSortIndicator method or the Column.ShowSortIndicator property.
To manually sort rows by more than one column (by more than one sort key), use the SortRows methods.
If you want to change the sort indicator shown for a column, use the SheetView.SetColumnSortIndicator method or the Column.SortIndicator property. These change the sort indicator in the column header and do not affect whether the column is sorted or not.