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
265
Sorting a text column as a number
posted

We are using 2006.1 Windows Forms Grids.   Is there any capability built in to the grids to sort a text(string) column as a number such that 1,2222,333,44 would sort properly as 1,44,333,2222?

This would be similar to the Excel (I know I shouldn't compare the WinGrids to Excel) function "Sort anything that looks like a number, as a number".

Does anyone have any advice on how to accomplish this?

Thanks for any advice!

Parents
  • 469350
    Verified Answer
    Offline posted

    The best way to get around is problem like this is not to store numbers as strings. Why not use a numeric data type? 

    If you can't do that, then you would have to create a custom SortComparer for the grid column.

Reply Children