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


column
Index of column to set
ascending
Whether sort is ascending (or else descending)
showIndicator
Whether to display the sort indicator
Automatically sorts the rows of a sheet according to the specified column in the specified order and using the sort indicator as specified.

Syntax

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

Parameters

column
Index of column to set
ascending
Whether sort is ascending (or else descending)
showIndicator
Whether to display the sort indicator

Example

This example sets whether to allow automatic sorting in the specified column, if it should be sorted in ascending order, and whether to show the sort indicator.

C#Copy Code
Random r = new Random();
int i, j;
for (i = 0; i<= 50; i++)
{
   
for (j = 0; j<=3; j++)
       fpSpread1.ActiveSheet.SetValue(i, j, r.Next(1, 200).ToString());
}
fpSpread1.ActiveSheet.AutoSortColumn(0, true, false);
Visual BasicCopy Code
Dim r As New Random()
Dim i, j As Integer
For i = 0 To 50
    For j = 0 To 3
        FpSpread1.ActiveSheet.SetValue(i, j, r.Next(1, 200).ToString())
    Next j
Next i
FpSpread1.ActiveSheet.AutoSortColumn(0, True, False)

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