CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 1999
    Location
    Montreal, Quebec, Canada
    Posts
    192

    Reverse sort order for comboboxes?

    Is there an easy way to sort in REVERSE order a Combo Box?


    ---
    Nicolas LeBlanc
    Software Engineer
    Ordiplan Inc.

  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Reverse sort order for comboboxes?

    AFAIK there is no way to change the sort order for a standard list or combobox.
    If you are as lazy as I am, and don't want to write the code for sorting, you can use a hidden Listview and add your items to the listview. The listview supports sorting in ascending or descending order.
    After sorting the listview you could then populate the combobox (Sorted=False) from the listview.
    It's definitely less code then implementing a sort algorithm.


  3. #3
    Join Date
    May 1999
    Location
    Omika, Japan
    Posts
    729

    Re: Reverse sort order for comboboxes?

    Quite often i do this, specially to sort strings. Use a hidden listbox...
    BTW, listbox could be less resource mongering than a LV, me thinks.. unless ofcourse the no.of items are going to run out of integer bounds.
    To sort in reverse order, copy the items bottom up.
    For i = List.Listcount-1 to 0 step -1

    RK

  4. #4
    Join Date
    Jul 1999
    Location
    Montreal, Quebec, Canada
    Posts
    192

    Re: Reverse sort order for comboboxes?

    Yes, this is what I did. Actually there is a better way by "switching" them (takes 1/2 of the time), but I was wondering about a "natural" way, inside VB itself..

    Since there isn't I did my own routine.


    ---
    Nicolas LeBlanc
    Software Engineer
    Ordiplan Inc.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured