CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2010
    Posts
    37

    How to sort a combobox after it has been created ?

    I have a combobox which doesn't have the CBS_SORT style and after adding some items I'd like to offer the ability for the user to sort it alphabetically by clicking on a given button.
    How can I sort the combobx after it has been created and some items added to it ?

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: How to sort a combobox after it has been created ?

    You have to destroy (or hide) this combox and create (or show) another one with the CBS_SORT style and then populate this new one with the same item list.
    Victor Nijegorodov

  3. #3
    Join Date
    Mar 2010
    Posts
    37

    Re: How to sort a combobox after it has been created ?

    Thank you !

  4. #4
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: How to sort a combobox after it has been created ?

    or
    get the contents of the combobox into an array
    clear the combobox
    sort the array
    fill the combobox in sorted order from the array

  5. #5
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: How to sort a combobox after it has been created ?

    Why not just create it initially with the CBS_SORT style?

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