ComponentOne FlexGrid for WinForms
In This Topic
    Sorting
    In This Topic

    To sort multiple columns, set each column's Sort property and use the Sort method to sort according to the column settings.

    1. Add the following code to the Form_Load event to set the second column to sort in ascending order and the third column to sort in descending order.

      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;
      
    2. Add the following Sort method to sort according to the settings in columns two and three.

      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);
      

    This topic illustrates the following:

    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.


    An image of FlexGrid application.
    Note: WinForms .NET 5 Edition has only runtime assemblies. Due to the new design-time model in VS2019 Preview, which is not complete yet from the Microsoft side, we do not supply any special design-time features as of yet. However, some of the controls might show up at design-time and allow editing few properties in the property grid.