FlexGrid for WinForms Task-Based Help > Sorting Multiple Columns |
To sort multiple columns, set each column's Sort property and use the Sort method to sort according to the column settings.
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Me.C1FlexGrid1.Cols(1).Sort = C1.Win.C1FlexGrid.SortFlags.Ascending Me.C1FlexGrid1.Cols(2).Sort = C1.Win.C1FlexGrid.SortFlags.Descending |
To write code in C#
C# |
Copy Code
|
---|---|
this.c1FlexGrid1.Cols[1].Sort = C1.Win.C1FlexGrid.SortFlags.Ascending; this.c1FlexGrid1.Cols[2].Sort = C1.Win.C1FlexGrid.SortFlags.Descending; |
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Me.C1FlexGrid1.Sort(C1.Win.C1FlexGrid.SortFlags.UseColSort, 1, 2) |
To write code in C#
C# |
Copy Code
|
---|---|
this.c1FlexGrid1.Sort(C1.Win.C1FlexGrid.SortFlags.UseColSort, 1, 2); |
Your grid will look like the following with the second column sorted in ascending order, then the third column in descending order. In this example, Neon appears before Argon in the Element column since the grid is sorted first by the StandardState column in ascending order, then by the Element column in descending order.