Custom Sort a bindingsource in ADO.NET (VB) RRS feed

  • Question

  • I have a field in a datatable that stores page numbers, but I have made it a string (text) field because at times it stores page ranges, such as "10-25", yet I want to sort this table according to the integer values of the pages, not a text sort which ends up putting page 18 after page 111.  Is there a way I can create a custom sort routine that the bindingsource.sort method will use, so that I can control how the rows are compared?


    Thanks very much!

    Abe Fisher

    Monday, July 14, 2008 6:35 PM

All replies

  • Yes, you can do it, but in this case you need to make all string numberss equal length with leading zeros. For example





    In this case string will be sorted according to your logic. Otherwise you need to store valuesas actual numbers


    Tuesday, July 15, 2008 2:32 AM