Spread Windows Forms 6.0 Product Documentation
Using Automatic Sorting
Support Options
Spread Windows Forms 6.0 Product Documentation > Developer's Guide > Customizing Row or Column Interaction > Managing Sorting of Rows of User Data > Using Automatic Sorting

Glossary Item Box

You can sort entire rows or columns automatically in a sheet. Automatically sort 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. This does not affect the data model, only how the data is displayed. Different overloads provide different ways to perform the sorting.

Use the AutoSortColumn method to sort the display in a sheet automatically according to the specified key and use the SetColumShowSortIndicator to set whether to show the sort indicator. The AutoSortColumn method performs the same action as clicking in the column header of the specified column that has its AllowAutoSort property set to True. (The AllowAutoSort 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 affects only the arrangement of rows or columns on a sheet and does not change the arrangement of the data; this does not affect the data model, only how the data is displayed. Several overloads of the method provide different ways to sort.

Note: The SetColumShowSortIndicator method must be called before the AutoSortColumn method. Otherwise, the sort indicator is shown and remains displayed.

Return to the overview at Managing Sorting of Rows of User Data.

Using Code

  1. Allow the automatic sorting of a column or columns.
  2. Set the column to show the sort indicator if desired.
  3. Perform the automatic sort.


This example automatically sorts the first column.

C# Copy Code
fpSpread1.ActiveSheet.SetColumnAllowAutoSort(0, true);
fpSpread1.ActiveSheet.SetColumnShowSortIndicator(0, false);
VB Copy Code
fpSpread1.ActiveSheet.SetColumnAllowAutoSort(0, True)
fpSpread1.ActiveSheet.SetColumnShowSortIndicator(0, False)

© 2002-2012 ComponentOne, a division of GrapeCity. All Rights Reserved.