Solved

Very easy about combobox

Posted on 2000-03-24
3
158 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Creating Labels and Frequency list style reports in SAS code 9 92
matchUp  challenge 6 52
pre4 challenge 19 93
noX challenge 17 91
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

919 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