FarPoint.Win.Spread
AutoSortColumn(Int32) Method
See Also  Example
FarPoint.Win.Spread Assembly > FarPoint.Win.Spread Namespace > SheetView Class > AutoSortColumn Method : AutoSortColumn(Int32) Method


column
Index of column to set
Automatically sorts the rows of a sheet according to the specified column.

Syntax

Visual Basic (Declaration) 
Public Overloads Sub AutoSortColumn( _
   ByVal column As Integer _
) 
Visual Basic (Usage)Copy Code
Dim instance As SheetView
Dim column As Integer
 
instance.AutoSortColumn(column)
C# 
public void AutoSortColumn( 
   int column
)

Parameters

column
Index of column to set

Example

This example adds random numbers to the sheet, and then auto sorts the column and displays the sort indicator.
C#Copy Code
Random r = new Random();
int i;
for (i = 0; i <= 200; i++)
{
   fpSpread1.ActiveSheet.SetValue(i, 0, r.Next().ToString());
}
fpSpread1.ActiveSheet.AutoSortColumn(0);
Visual BasicCopy Code
Dim r As New Random()
Dim i As Integer
For i = 0 To 200
    FpSpread1.ActiveSheet.SetValue(i, 0, r.Next.ToString())
Next
FpSpread1.ActiveSheet.AutoSortColumn(0)

Remarks

See the explanation in the AutoSortColumn methods overview.

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.

See Also