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. Combo Box Error

Combo Box Error

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++
3 Posts 2 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.
  • V Offline
    V Offline
    vc programmer 0
    wrote on last edited by
    #1

    My error! First time!i choice Two.m_cbodata is Two. Second time!i choice One.m_cbodata is Two. When i choice ,my Combo Box data is not change. I don't know what happen. pls help me. My code is following...... //MyView.h public: //{{AFX_DATA(CMyView) CString m_cbodata; //}}AFX_DATA //MyView.cpp void Click() { UpdateData(TRUE); if (m_cbodata=="One") { AfxMessageBox("One"); } if (m_cbodata=="Two") { AfxMessageBox("Two"); } }

    V 1 Reply Last reply
    0
    • V vc programmer 0

      My error! First time!i choice Two.m_cbodata is Two. Second time!i choice One.m_cbodata is Two. When i choice ,my Combo Box data is not change. I don't know what happen. pls help me. My code is following...... //MyView.h public: //{{AFX_DATA(CMyView) CString m_cbodata; //}}AFX_DATA //MyView.cpp void Click() { UpdateData(TRUE); if (m_cbodata=="One") { AfxMessageBox("One"); } if (m_cbodata=="Two") { AfxMessageBox("Two"); } }

      V Offline
      V Offline
      vc programmer 0
      wrote on last edited by
      #2

      i found my error!!! i change following code!!!! //MyView.cpp if (0==m_ctrldevice.GetCurSel( )) { AfxMessageBox("One"); } if (1==m_ctrldevice.GetCurSel( )) { AfxMessageBox("Two"); }

      B 1 Reply Last reply
      0
      • V vc programmer 0

        i found my error!!! i change following code!!!! //MyView.cpp if (0==m_ctrldevice.GetCurSel( )) { AfxMessageBox("One"); } if (1==m_ctrldevice.GetCurSel( )) { AfxMessageBox("Two"); }

        B Offline
        B Offline
        BlackDice
        wrote on last edited by
        #3

        how about this:

        CString str;
        str.Format("%d",m_ctrldevice.GetCurSel() + 1); //add 1, since Sel is 0-based.
        AfxMessageBox(str);
        

        this will display a messagebox with "1","2", or whatever the cursel is. If I write code in my sleep, does that make me brilliant, or just a lazy programmer? My articles www.stillwaterexpress.com BlackDice - the programmer formerly known as bdiamond

        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