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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. ComboBox sorting

ComboBox sorting

Scheduled Pinned Locked Moved C / C++ / MFC
algorithmshelp
14 Posts 4 Posters 0 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.
  • R raju_shiva

    Hi sir, I have selected the CBS_SORT,its sorting correctly. My doubt is if we type manually in the edit box for ex : "a" In the combbox only the data starting from "a" should be seen in the dropdown Combobox Ex a,aa,aa Not the b,bb,bbb values I hope you got it now. Thanks Raj

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #4

    OK, I misunderstood your question. In this case you will need to filter the data in the combobox yourself, I don't know of any built in message that allows you to do this.

    It's time for a new signature.

    R 1 Reply Last reply
    0
    • R raju_shiva

      Hi, I am new bie to Dialog Based, I have a combobox and i am reading some values from it. For ex : the values are a,aa,aaa,b,bb,bbb I have set the properties as DropDown,Sort and verticalScroll. If i enter the any value in editbox. For ex if i enter "a" in edit box. I have to get values in sorted Ex a,aa,aaa Any help appreciated Thanks Raj

      A Offline
      A Offline
      Anand Todkar
      wrote on last edited by
      #5

      If i undrstood you correctly, you want an Auto Complete functionality which we see many times in web based applications (In Google Search if we typed "as" then strings starting with "as" will appear in drop down automatically). For this to achieve, refer here[^], see if this is useful any way. Good Luck.

      Thanks, Anand.

      R 2 Replies Last reply
      0
      • A Anand Todkar

        If i undrstood you correctly, you want an Auto Complete functionality which we see many times in web based applications (In Google Search if we typed "as" then strings starting with "as" will appear in drop down automatically). For this to achieve, refer here[^], see if this is useful any way. Good Luck.

        Thanks, Anand.

        R Offline
        R Offline
        raju_shiva
        wrote on last edited by
        #6

        Hi sir, Thanks for your reply. Actually i have combobox where i will read some data from DataBase. I have set the properties to SORT,DropDown. When i click the dropdown,its sorting and showing the values in the combobox(dropdown) correctly. But what i need if i type manually any data in Combo(editable) Example "a",i should get the the names starting from "a" and show the list in ComboNox(dropdown). I hope thant now i am clear. I am in doubt.whethier i have to change the properties of combobox or store all the values in array and sort it according. Plz do the needful Thanks Sharan

        D 1 Reply Last reply
        0
        • R raju_shiva

          Hi sir, Thanks for your reply. Actually i have combobox where i will read some data from DataBase. I have set the properties to SORT,DropDown. When i click the dropdown,its sorting and showing the values in the combobox(dropdown) correctly. But what i need if i type manually any data in Combo(editable) Example "a",i should get the the names starting from "a" and show the list in ComboNox(dropdown). I hope thant now i am clear. I am in doubt.whethier i have to change the properties of combobox or store all the values in array and sort it according. Plz do the needful Thanks Sharan

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

          See here.

          "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
          • L Lost User

            OK, I misunderstood your question. In this case you will need to filter the data in the combobox yourself, I don't know of any built in message that allows you to do this.

            It's time for a new signature.

            R Offline
            R Offline
            raju_shiva
            wrote on last edited by
            #8

            OK, I misunderstood your question. In this case you will need to filter the data in the combobox yourself, I don't know of any built in message that allows you to do this. Hi sir I am not clear with this,"Filter the data in combo box" in the sense. Whetheir i have to read the data and sort it. Thanks Raj

            L 1 Reply Last reply
            0
            • R raju_shiva

              OK, I misunderstood your question. In this case you will need to filter the data in the combobox yourself, I don't know of any built in message that allows you to do this. Hi sir I am not clear with this,"Filter the data in combo box" in the sense. Whetheir i have to read the data and sort it. Thanks Raj

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #9

              You can check the suggestion of Anand below, which may be the solution to your problem. Alternatively to do it yourself you will need to implement a catch for the CBN_DROPDOWN notification. You then populate the list items based on the contents of the edit box. There are problems of course when the user then changes the content of the edit box by backspace and retyping.

              It's time for a new signature.

              R 1 Reply Last reply
              0
              • L Lost User

                You can check the suggestion of Anand below, which may be the solution to your problem. Alternatively to do it yourself you will need to implement a catch for the CBN_DROPDOWN notification. You then populate the list items based on the contents of the edit box. There are problems of course when the user then changes the content of the edit box by backspace and retyping.

                It's time for a new signature.

                R Offline
                R Offline
                raju_shiva
                wrote on last edited by
                #10

                Hi sir, Thanks for all your help.I have found the solution. I am reading all the character from combo and storing it in map. then i am reading the character from combo and Find() in given whole map. I am tryig this code.

                CString strValue;
                CString strTemp;
                m_CtrlComboID.GetWindowText(strValue);
                std::map<CString,CString>::iterator it=m_mapId.begin();
                m_CtrlComboID.ResetContent();
                for(; it!=m_mapId.end(); it++)
                {
                strTemp = it->first;
                strValue.MakeUpper();
                if(strTemp.Find(strValue)==0)
                m_PatientID.AddString(strTemp);
                }
                m_CtrlComboID.SetWindowText(strValue);
                m_CtrlComboID.ShowDropDown();

                the problem i am facing is, 1)The first string is getting set in the ComboBox. 2)when i type the first character in combo,it is getting the strings related to the first character. but i am not able to type in the second character,as the cursor is going in the first position. The character which i have typed later is going first. For Ex: First i will type the character as "P", Second if i type "A" character in combo,its going before "P" i.e "AP",but i need as "PA". I am bit confused, any suggestions Thanks Raj

                L 1 Reply Last reply
                0
                • A Anand Todkar

                  If i undrstood you correctly, you want an Auto Complete functionality which we see many times in web based applications (In Google Search if we typed "as" then strings starting with "as" will appear in drop down automatically). For this to achieve, refer here[^], see if this is useful any way. Good Luck.

                  Thanks, Anand.

                  R Offline
                  R Offline
                  raju_shiva
                  wrote on last edited by
                  #11

                  Hi sir, Thanks for your reply,For me sorting is working properly. My problem is only the cursor is reseting in the first position sir.Its not coming after the character typed Thanks Raj

                  A 1 Reply Last reply
                  0
                  • R raju_shiva

                    Hi sir, Thanks for your reply,For me sorting is working properly. My problem is only the cursor is reseting in the first position sir.Its not coming after the character typed Thanks Raj

                    A Offline
                    A Offline
                    Anand Todkar
                    wrote on last edited by
                    #12

                    Great, I also faced the same problem but i remember it gets fixed by some flags, please refer to article again and the additional flags. Keep it up.

                    Thanks, Anand.

                    R 1 Reply Last reply
                    0
                    • A Anand Todkar

                      Great, I also faced the same problem but i remember it gets fixed by some flags, please refer to article again and the additional flags. Keep it up.

                      Thanks, Anand.

                      R Offline
                      R Offline
                      raju_shiva
                      wrote on last edited by
                      #13

                      Hello sir, I tried running that demo version. but i got the error as "cannot open include file 'atlres.h'." From where i will get the header file. Thanks Sharan

                      1 Reply Last reply
                      0
                      • R raju_shiva

                        Hi sir, Thanks for all your help.I have found the solution. I am reading all the character from combo and storing it in map. then i am reading the character from combo and Find() in given whole map. I am tryig this code.

                        CString strValue;
                        CString strTemp;
                        m_CtrlComboID.GetWindowText(strValue);
                        std::map<CString,CString>::iterator it=m_mapId.begin();
                        m_CtrlComboID.ResetContent();
                        for(; it!=m_mapId.end(); it++)
                        {
                        strTemp = it->first;
                        strValue.MakeUpper();
                        if(strTemp.Find(strValue)==0)
                        m_PatientID.AddString(strTemp);
                        }
                        m_CtrlComboID.SetWindowText(strValue);
                        m_CtrlComboID.ShowDropDown();

                        the problem i am facing is, 1)The first string is getting set in the ComboBox. 2)when i type the first character in combo,it is getting the strings related to the first character. but i am not able to type in the second character,as the cursor is going in the first position. The character which i have typed later is going first. For Ex: First i will type the character as "P", Second if i type "A" character in combo,its going before "P" i.e "AP",but i need as "PA". I am bit confused, any suggestions Thanks Raj

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #14

                        Sorry, but I don't have MFC so I cannot reproduce the problem on my system. I wonder if any other kind reader has more experience with CComboBox.

                        It's time for a new signature.

                        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