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. CCombobox MFC vc++

CCombobox MFC vc++

Scheduled Pinned Locked Moved C / C++ / MFC
c++
12 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.
  • M Offline
    M Offline
    Member_14575556
    wrote on last edited by
    #1

    I have created a CCombobox drop down and added three data through wizards and disable editing. I wanted to display some data/word initially in the edit ctrl part of the CCombobox before selecting the data present in the drop down.I having difficulty achieving this, could I have some pointers regarding this. Thanks in advance.

    V L 2 Replies Last reply
    0
    • M Member_14575556

      I have created a CCombobox drop down and added three data through wizards and disable editing. I wanted to display some data/word initially in the edit ctrl part of the CCombobox before selecting the data present in the drop down.I having difficulty achieving this, could I have some pointers regarding this. Thanks in advance.

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #2

      To display some existing (in the combo listbox) item use CComboBox::SetCurSel. To display some arbitrary text you could use SetWindowText method.

      M 1 Reply Last reply
      0
      • M Member_14575556

        I have created a CCombobox drop down and added three data through wizards and disable editing. I wanted to display some data/word initially in the edit ctrl part of the CCombobox before selecting the data present in the drop down.I having difficulty achieving this, could I have some pointers regarding this. Thanks in advance.

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

        See CComboBox Class, SelectString method[^]

        M 1 Reply Last reply
        0
        • V Victor Nijegorodov

          To display some existing (in the combo listbox) item use CComboBox::SetCurSel. To display some arbitrary text you could use SetWindowText method.

          M Offline
          M Offline
          Member_14575556
          wrote on last edited by
          #4

          Thanks for replying. Yes, I've tried using SetWindowText method. It's not showing in the combo box. What I wanted was when I start my application it shows something like "please select something" before I select anything. For edit ctrl box... We assigned something to the CSting variable and do UpdataData(FALSE).. I wanted to do something similar like this. Thanks again.

          D V 2 Replies Last reply
          0
          • M Member_14575556

            Thanks for replying. Yes, I've tried using SetWindowText method. It's not showing in the combo box. What I wanted was when I start my application it shows something like "please select something" before I select anything. For edit ctrl box... We assigned something to the CSting variable and do UpdataData(FALSE).. I wanted to do something similar like this. Thanks again.

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

            Member 14575556 wrote:

            What I wanted was when I start my application it shows something like "please select something" before I select anything.

            Are you doing something like:

            m_list.AddString(_T("Item 1"));
            m_list.AddString(_T("Item 2"));
            m_list.AddString(_T("Item 3"));
            m_list.AddString(_T("Item 4"));
            m_list.InsertItem(0, _T("please select something"));
            ...
            m_list.SetCurSel(0);

            "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

            "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

            1 Reply Last reply
            0
            • M Member_14575556

              Thanks for replying. Yes, I've tried using SetWindowText method. It's not showing in the combo box. What I wanted was when I start my application it shows something like "please select something" before I select anything. For edit ctrl box... We assigned something to the CSting variable and do UpdataData(FALSE).. I wanted to do something similar like this. Thanks again.

              V Offline
              V Offline
              Victor Nijegorodov
              wrote on last edited by
              #6

              Member 14575556 wrote:

              Yes, I've tried using SetWindowText method. It's not showing in the combo box.

              It does work for me. Perhaps, you used DropdownList combo?

              D 1 Reply Last reply
              0
              • V Victor Nijegorodov

                Member 14575556 wrote:

                Yes, I've tried using SetWindowText method. It's not showing in the combo box.

                It does work for me. Perhaps, you used DropdownList combo?

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

                Victor Nijegorodov wrote:

                Perhaps, you used DropdownList combo?

                Is that an MFC control?

                "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

                "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

                V 1 Reply Last reply
                0
                • D David Crow

                  Victor Nijegorodov wrote:

                  Perhaps, you used DropdownList combo?

                  Is that an MFC control?

                  "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

                  "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

                  V Offline
                  V Offline
                  Victor Nijegorodov
                  wrote on last edited by
                  #8

                  Yes. I meant the MFC combobox with CBS_DROPDOWNLIST style.

                  M 1 Reply Last reply
                  0
                  • V Victor Nijegorodov

                    Yes. I meant the MFC combobox with CBS_DROPDOWNLIST style.

                    M Offline
                    M Offline
                    Member_14575556
                    wrote on last edited by
                    #9

                    Yes, I used MFC combobox with CBS_DROPDOWNLIST style.

                    V 1 Reply Last reply
                    0
                    • L Lost User

                      See CComboBox Class, SelectString method[^]

                      M Offline
                      M Offline
                      Member_14575556
                      wrote on last edited by
                      #10

                      Thank you. This really match with what I wanted to do. :)

                      L 1 Reply Last reply
                      0
                      • M Member_14575556

                        Thank you. This really match with what I wanted to do. :)

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

                        You are welcome. It always pays to check the documentation first.

                        1 Reply Last reply
                        0
                        • M Member_14575556

                          Yes, I used MFC combobox with CBS_DROPDOWNLIST style.

                          V Offline
                          V Offline
                          Victor Nijegorodov
                          wrote on last edited by
                          #12

                          Member 14575556 wrote:

                          Yes, I used MFC combobox with CBS_DROPDOWNLIST style.

                          Then you will only able to display a string already inserted in the combo listbox. Use either CComboBox::SelectString or CComboBox::SetCurSel.

                          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