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

Glossary Item Box

You can sort the data displayed in the sheet either by column or by row. Typically, all the rows of a sheet are sorted by the values in a particular column. But Spread allows various ways of performing a sort with various properties and methods for each type of sorting. In general, sorting data can be done by any of these ways:

There are various properties of sorting. The order of the sort can be in ascending order (A to Z, zero to 9) or descending order (Z to A, 9 to zero). The method of comparison can be customized. You can select which values to use as a key when comparing in order to sort the values. The sort indicator, an arrow typically, can be displayed in the header for the column being used as a sort key. For more information on customizing the sorting, refer to the SortInfo object. With this object, you can set the parameters for sorting and then specify this object in the particular sort method you choose.

The cell type does not matter for sorting. The sorting is done depending on the data type of the values in the cells. If you sort cells with data of the DateTime type, then it sorts those cells by date, and if you sort cells with data of the string type, it sorts those cells alphabetically.

Be aware of how sorting works with the data in the models. If you use the automatic sorting by clicking the column header or you call the SortRows method of the sheet, then the data model is not sorted, just the data that is displayed to the user. In this case, any data that is hidden before the sort is hidden after the sort, since Spread moves any hidden rows automatically. If you use the SortRange method, the data is sorted in the data model and data that is hidden may become visible and vice versa using this method. When you sort data, only the data model is getting sorted. The SelectionModel does not get sorted. If you want the selected row to move, you would need to write code in the AutoSortedColumn and AutoSortingColumn events to move the selection. For more information on the models, refer to Understanding the Underlying Models.

Sorting executed by clicking column headers sorts only the displayed data and does not affect the order of actual data in the data model. So you can reset the sorted data being displayed to the order of actual data by calling either the ResetViewRowIndexes method or the ResetViewColumnIndexes method in the SheetView.DocumentModels class. You cannot reset, however, the result when the actual data in the data model are sorted with the SortRange method in the SheetView class.

Also, sorting is not intended to be used when Outlook-style grouping is turned on. For more information about grouping (which is its own way a type of sorting), refer to Managing Grouping of Rows of User Data.

For information on sorting within the Spread Designer, refer to the Spread Designer Guide.

Note: Cell spans become invisible when sorting a sheet with any method except SortRange.

Return to the overall list of tasks in Customizing Row or Column Interaction.

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