Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Very easy about combobox

Posted on 2000-03-24
3
Medium Priority
?
176 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 300 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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…
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 lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

824 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