Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to disable auto sorting for CComboBox

How to disable auto sorting for CComboBox

Scheduled Pinned Locked Moved C / C++ / MFC
algorithmstutorialquestion
3 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TechAvtar
    wrote on last edited by
    #1

    Hi I have a CComboBox, I am populating items into that. But when i run the code, the inserted items are getting sorted in the combo box. But I want to keep the order of *inertion* in the display. How to do this? Thanks JC CComboBox* comboComSelection; comboComSelection = ((CComboBox*)GetDlgItem (IDC_COM_COMBO)); comboComSelection->ResetContent(); comboComSelection->AddString (_T ("COM1")); comboComSelection->AddString (_T ("COM2")); comboComSelection->AddString (_T ("COM10")); ( I need COM1, COM2, COM10 in the order, when combo box appears)

    D T 2 Replies Last reply
    0
    • T TechAvtar

      Hi I have a CComboBox, I am populating items into that. But when i run the code, the inserted items are getting sorted in the combo box. But I want to keep the order of *inertion* in the display. How to do this? Thanks JC CComboBox* comboComSelection; comboComSelection = ((CComboBox*)GetDlgItem (IDC_COM_COMBO)); comboComSelection->ResetContent(); comboComSelection->AddString (_T ("COM1")); comboComSelection->AddString (_T ("COM2")); comboComSelection->AddString (_T ("COM10")); ( I need COM1, COM2, COM10 in the order, when combo box appears)

      T Offline
      T Offline
      TechAvtar
      wrote on last edited by
      #2

      Hmm.. I got the answer.. disable the sort property in GUI.

      1 Reply Last reply
      0
      • T TechAvtar

        Hi I have a CComboBox, I am populating items into that. But when i run the code, the inserted items are getting sorted in the combo box. But I want to keep the order of *inertion* in the display. How to do this? Thanks JC CComboBox* comboComSelection; comboComSelection = ((CComboBox*)GetDlgItem (IDC_COM_COMBO)); comboComSelection->ResetContent(); comboComSelection->AddString (_T ("COM1")); comboComSelection->AddString (_T ("COM2")); comboComSelection->AddString (_T ("COM10")); ( I need COM1, COM2, COM10 in the order, when combo box appears)

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        TechAvtar wrote:

        How to do this?

        By removing the CBS_SORT style. You can do this at design time or at run time.

        "One man's wage rise is another man's price increase." - Harold Wilson

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        "Man who follows car will be exhausted." - Confucius

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups