Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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

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

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Suggested Courses

569 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