Solved

Initializing A ComboBox

Posted on 2001-06-12
6
690 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Generic progress indicator 6 117
Expand data scrubbing tool 13 35
method notes when mouse over in eclipse 5 87
viewing source code from eclipse 13 110
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

792 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