Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Very easy about combobox

Posted on 2000-03-24
3
Medium Priority
?
173 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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: 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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

704 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