[]
        
(Showing Draft Content)

Sorting Columns

Sorting is an important requirement when it comes to listing data alphabetically and arranging data in ascending or descending order. C1FlexSheet uses AllowSorting property to sort data in a worksheet.

In XAML

You can easily sort data using AllowSorting property in XAML View. The following code illustrates the use of AllowSorting property:

<c1:C1FlexSheet x:Name="flexsheet" AllowDragging="Columns" AllowSorting="True" Margin="0,25,0,0"/>

In Code

The following code illustrates the use of AllowSorting property in Code view:

vbnet

flexsheet.AllowSorting = True

csharp

flexsheet.AllowSorting = true;

The C1FlexSheet control also provides range-based unbound sorting. Sorting in FlexSheet can be done by using SortDialog class. The following lines of code show the unbound sorting in C1FlexSheet control:

vbnet

If flexsheet.Columns.Count > 0 Then
    Dim sortDialog = New SortDialog(flexsheet)
    sortDialog.Show()
End If

csharp

if (flexsheet.Columns.Count > 0)
{
    var sortDialog = new SortDialog(flexsheet);
    sortDialog.Show();
} 

The Sort dialog box provides options of adding, deleting, and copying levels. You can specify columns and their respective orders (ascending or descending) for sorting data in these levels.

Sort dialog box