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. how to display text in a combo box edit control

how to display text in a combo box edit control

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
5 Posts 3 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.
  • E Offline
    E Offline
    elephantstar
    wrote on last edited by
    #1

    I have a dropdown combo box that needs to be able to accept new entries not listed in the combo box via the edit control. If I create the member variable as a value instead of control, I'm able to save the selection or text input, but how do I display it in the edit control when I reopen the window. I tried the following: private: CString test_value; test_value = m_test; //Saves the selection //m_test = test_value; //tried this first GetDlgItem(IDC_TEST)->SetWindowText(m_test); //this didn't work either UpdateData(FALSE); Please help! Thanks.

    C A 2 Replies Last reply
    0
    • E elephantstar

      I have a dropdown combo box that needs to be able to accept new entries not listed in the combo box via the edit control. If I create the member variable as a value instead of control, I'm able to save the selection or text input, but how do I display it in the edit control when I reopen the window. I tried the following: private: CString test_value; test_value = m_test; //Saves the selection //m_test = test_value; //tried this first GetDlgItem(IDC_TEST)->SetWindowText(m_test); //this didn't work either UpdateData(FALSE); Please help! Thanks.

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      elephantstar wrote:

      GetDlgItem(IDC_TEST)->SetWindowText(m_test); //this didn't work either UpdateData(FALSE);

      does SetWindowText still not work if you get rid of the UpdateData call ? Cleek | Image Toolkits | Thumbnail maker

      E 1 Reply Last reply
      0
      • C Chris Losinger

        elephantstar wrote:

        GetDlgItem(IDC_TEST)->SetWindowText(m_test); //this didn't work either UpdateData(FALSE);

        does SetWindowText still not work if you get rid of the UpdateData call ? Cleek | Image Toolkits | Thumbnail maker

        E Offline
        E Offline
        elephantstar
        wrote on last edited by
        #3

        Yes.

        1 Reply Last reply
        0
        • E elephantstar

          I have a dropdown combo box that needs to be able to accept new entries not listed in the combo box via the edit control. If I create the member variable as a value instead of control, I'm able to save the selection or text input, but how do I display it in the edit control when I reopen the window. I tried the following: private: CString test_value; test_value = m_test; //Saves the selection //m_test = test_value; //tried this first GetDlgItem(IDC_TEST)->SetWindowText(m_test); //this didn't work either UpdateData(FALSE); Please help! Thanks.

          A Offline
          A Offline
          Andy Rama
          wrote on last edited by
          #4

          Hi, I don't have more knowlegde about VC++, but try following if it can satisfy your requirement.

          //Adds a string in ComboBox
          CComboBox *combo = new CComboBox();
          combo->m_hWnd = GetDlgItem(IDC_TEST)->m_hWnd;
          combo->AddString("AS");
          combo->AddString("ZX"); //Adds a string in ComboBox at Last Position
          //if 'Sort' option is not Selected.

          //Following shows the text in ComboBox (must not be in the list of ComboBox)
          m_combo = "ZX"; //where 'm_combo' member variable of 'IDC_TEST' ComboBox
          // datatype of 'm_combo' is 'CString'
          UpdateData(FALSE);

          Try it. Best Regards, Aniket -- modified at 9:07 Friday 19th May, 2006

          E 1 Reply Last reply
          0
          • A Andy Rama

            Hi, I don't have more knowlegde about VC++, but try following if it can satisfy your requirement.

            //Adds a string in ComboBox
            CComboBox *combo = new CComboBox();
            combo->m_hWnd = GetDlgItem(IDC_TEST)->m_hWnd;
            combo->AddString("AS");
            combo->AddString("ZX"); //Adds a string in ComboBox at Last Position
            //if 'Sort' option is not Selected.

            //Following shows the text in ComboBox (must not be in the list of ComboBox)
            m_combo = "ZX"; //where 'm_combo' member variable of 'IDC_TEST' ComboBox
            // datatype of 'm_combo' is 'CString'
            UpdateData(FALSE);

            Try it. Best Regards, Aniket -- modified at 9:07 Friday 19th May, 2006

            E Offline
            E Offline
            elephantstar
            wrote on last edited by
            #5

            Thanks. That worked.

            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