Solved

Initializing A ComboBox

Posted on 2001-06-12
6
692 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
Technology Partners: 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 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

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
if loop in java 3 174
java ^ examples 8 73
Annoying "thing" blocks my view 4 143
Path of Workbook 3 87
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…
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

739 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