UpdateData not working with Dropdown style CComboBox

Posted on 2003-03-24
Medium Priority
Last Modified: 2013-11-20
I understand that UpdateData is not supposed to work with the Droplist style of combobox, but I have a DropDown style combobox that it is not working with.  It is a pretty simple set of code, just created the dialog in the resources and had classwizard add member variables for 2 combo boxes.  From the ON_CBN_SELCHANGE handler I tried setting the member variable by calling UpdateData().  It returns 1 but the value of the member variable does not change.  I tested the value in the combobox by immediately calling GetLBText to retrieve the data, and that works fine.

What could I be doing that the UpdateData() is not working?
Urgently awaiting an answer,
Question by:appleby
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Author Comment

ID: 8197381
Here are snippets of the key pieces of code:

void CVersionPage::DoDataExchange(CDataExchange* pDX)
     DDX_CBString(pDX, IDC_VERSION, m_strVersion);

void CVersionPage::OnSelchangeVersion()
    UpdateData(); // I examine the value of m_strVersion here and find no change.

The declaration in the .h file:
// Dialog Data
     enum { IDD = IDD_VERSION_DLG };
     CString     m_szVersion;


Author Comment

ID: 8197401
Oops, I copied the .h snippet just now from an old copy of the file - indeed I did change all the names to m_strVersion, so I do not really have a mismatch between m_szVersion and m_strVersion as it appears.  The problem exists with m_strVersion as the filename in all locations.
Sorry for the confusion.

Expert Comment

ID: 8197797
I seem to recall having this problem a long time ago too.   The call to UpdateData in the CBN_SELCHANGE event returns the previous value of the edit box not the current value.

An idea would be to try CBN_EDITCHANGE.

Failing that why not just use GetLBText, which you know works OK?
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 8197893
Ok, I just tried CBN_EDITCHANGE (which seems like a good idea since it gets called after the text has changed) but it made no difference.  Thanks for the suggestion though.

Yes, I am using GetLBText for now but would prefer to use UpdateData if I could make it work.  


Expert Comment

ID: 8200983
I got the same problem few days ago and solved it with CBN_SELCHANGE this way:

void CUnit::OnSelChangeComboOIT()
     int iOIT = m_cbOIT.GetCurSel();
//m_cbOIT = member variable associated to combobox

Maybe it could help you

Accepted Solution

modulo earned 0 total points
ID: 11825066
PAQed - no points refunded (of 500)

Community Support Moderator

Featured Post

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month10 days, 18 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question