Solved

Very easy about combobox

Posted on 2000-03-24
3
157 Views
Last Modified: 2013-11-20
I have a combobox, with a member variable m_SC, type: CCombobox.

How can I access the selected item and use it as a CString??

I thought it was something like:
CString string=m_SC.GetEditSel;

or
CString string = m_SC.GetItemData(0);

but none of them work.
0
Comment
Question by:caiman23
3 Comments
 
LVL 5

Accepted Solution

by:
proskig earned 75 total points
Comment Utility
Hi,
First of all, you can add member variable of CString type and associate it with this ComboBox. Otherwise you can use m_SC.GetWindowText(str);

Regards,
Igor
0
 
LVL 30

Expert Comment

by:Zoppo
Comment Utility
Hi caiman23,

CString string;
int item = m_SC.GetCurSel();
if ( item != CB_ERR )
{
 m_SC.GetLBText( item, string );
}

ZOPPO
0
 

Author Comment

by:caiman23
Comment Utility
OK, thank you. So I use this code:

void CFhgDlg::OnSelchangeSc()
{
      UpdateData(FALSE);
      CString str;
      m_SC.GetWindowText(str);
      MessageBox(str);
}

But what I get in str is the OLD value of the combobox, not the new one -which I need in fact-

So, for instance, I have these elements in my combobox:

       Spring
       Summer  (Selected)
       Autumn
       Winter

"Summer" is selected. When I change to "Winter" and use the above code, I get in my MessageBox "Summer"... ??????

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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: 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.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now