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

x
?
Solved

Initializing A ComboBox

Posted on 2001-06-12
6
Medium Priority
?
695 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
[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
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

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

Accepted Solution

by:
sri_darr earned 800 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
In this post we will learn different types of Android Layout and some basics of an Android App.
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 is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

722 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