How to sort a combobox after it has been created ?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

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

  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 online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,286

    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
    3,765

    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
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,266

    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
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center