Solved

Initializing A ComboBox

Posted on 2001-06-12
6
685 Views
Last Modified: 2013-11-20
Hi,

I would like to add a combobox to my interface that will initially highlight a selection and include a list of options in the accompanying drop-down-list.  

I want to use the drop-down-list combobox because it does not allow users to type any information into the edit control.  However, I want to feed the combobox a string to display to the user intially using SetWindowText.  My problem is that I can't get SetWindowText to work with the drop-down-list combobox only the drop-down combo box.  Any suggestions for how I can get around this.

Thanks!
0
Comment
Question by:cneaton
6 Comments
 
LVL 6

Expert Comment

by:MichaelS
ID: 6182207
how to set the last one (for example)

// Select the last item in the combo box.
int nCount = pmyComboBox->GetCount();
if (nCount > 0)
   pmyComboBox->SetCurSel(nCount-1);


0
 

Author Comment

by:cneaton
ID: 6182250
Hi and thanks for the reply.  I actually need to extract some information from a file to display to the user in the interface.  So, I'll need to get the data from the file and then put it into the edit control.  However, the drop-down-list combobox won't let me do it.  I guess I could get the data from the file and then match it up to the available selections in the list and then set the display that way.  I was just wondering if there was an easier way.

Thanks again!
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 6182380
u can change the style of the combobox on runtime from drop-down to frop-list
0
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

 
LVL 4

Expert Comment

by:aponcealbuerne
ID: 6182444
try with AddString
Hope helps
0
 
LVL 4

Accepted Solution

by:
sri_darr earned 200 total points
ID: 6183434
Get the data from the file (say csData), and then

if (m_pMyCombo->FindString(csData) == CB_ERR)
{
    m_pMyCombo->AddString(csData);
}
m_pMyCombo->SelectString(-1, csData);


// Is this what u want ???
0
 

Author Comment

by:cneaton
ID: 6183593
Thanks so much, sri_darr!  This worked out great!  

I just have one note to future users,  FindString uses more than one parameter:
FindString( int nStartAfter, LPCTSTR lpszString )

Thanks again to everyone who responded!!!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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 demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

746 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

10 Experts available now in Live!

Get 1:1 Help Now