Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
440
IComparer Sort Not Working on UltraWinGrid
posted

I have implemented an IComparer class to use on a column that can contain numbers or strings. I'm assigning the comparer in the constructor of the form that has the grid:

grid.DisplayLayout.Bands[0].Columns["Number"].SortComparer = new InvoiceNumberSort();

The comparer works as expected when tested on an arraylist of values (so I know that's not the problem), but when the columnheader is clicked on the grid it appears to be using the default sorter. The HeadClickAction is set to SortSingle

e.g.  the expected order is 1,8921,8923,8931,28000,z3423

but the actual order is  1, 28000,8921,8923,8931,z3423

Is there anything else I need to do to get the sort to work when the user sorts on the header?

Parents
No Data
Reply
  • 69832
    Offline posted

    It looks like the values are being sorted by textual rules rather than by value. If there is a ValueList assigned to the column, how the ValueList is configured to affect sorting can affect this, although I thought assigning a SortComparer would override that behavior.

    One thing you can do is put a breakpoint in the Compare method of your IComparer implementation, and step through the code to see why it is sorting differently than you intended. You can also post a simple sample here if you like and we can take a look.

Children