Home - Forums-.NET - FlyGrid.Net (Windows Forms) - Sorting multiple columns problem

FlyGrid.Net (Windows Forms)

.NET Datagrid - Fast, highly customizable, industry standards .NET data grid control for WinForms

This forum related to following products: FlyGrid.Net

Sorting multiple columns problem
Link Posted: 01-Dec-2005 18:24
I am having problems sorting on multiple columns programmatically.  I have 2 numeric columns, which I want to sort with one as a primary sort, and the other as a secondary sort.

I have a grid of about 1500 rows.  Id is a unique numeric id column, and Type is a numeric column with (duplicate) values of 1, 2 or 3.  I want the type to be the primary sort, and then sorted secondly by ascending id.  This may be complicated by the fact that the type column is not visible, but I've tried making it visible to no noticeable difference.

I have tried the code from the help file :

  grid.BeginInit();
  try
  {
    grid.Columns.Items[0].SortOrder = SortOrder.Ascending;
    grid.Columns.Items[1].SortOrder = SortOrder.Descending;
    grid.Rows.Sort(grid.Columns.SortColumns);
  }
  finally
  {
    grid.EndInit();
  }  

However, on inspection, the "sortColumns" collection has a length of 1, and you don't get the expected result.

I have tried putting the two columns into an array, and then passing that array to the "sort" method, but that does not seem to work any better.

Any help, suggestions?
Link Posted: 07-Dec-2005 23:00
This problem is solved in the v1.2.9, see the Mester/Detail sample to be sure that multiple columns is sorted correctly in all levels of FlyGrid.