Solved

Very easy about combobox

Posted on 2000-03-24
3
159 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
ID: 2653116
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 31

Expert Comment

by:Zoppo
ID: 2653130
Hi caiman23,

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

ZOPPO
0
 

Author Comment

by:caiman23
ID: 2653269
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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Folder Comparison 12 54
Creating Labels and Frequency list style reports in SAS code 9 98
isEverywhere  challenge 19 78
fix34  challenge 9 123
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

831 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