Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combobox text manipulation

Status
Not open for further replies.

funnyrat

Programmer
Jul 27, 2006
3
0
0
US
I have a combobox that I would like to manipulate. Specifically, I'd like to change the text that's displayed in the unexpanded box.

I have no problem doing this when I assign a member variable as a CString, but since I'm using a Control variable, I haven't been able to change the caption text. Any help would be appreciated. Thank you.
 
If the ComboBox is of DropDown type, SetWindowText sets the text in unexpanded field.
If the ComboBox is of DropList type, SelectString sets the text, as you can only see values provided in the list.

------------------
When you do it, do it right.
 
I'm using a droplist. The SelectString function works only if I use it in the InitialDialog method, but it's not working with my particular code.

I'm using a "Browse..." search file process. Once the user clicks the button and chooses a file from the dialog, the directory's string is stored. At this point, I add the string to the combobox using AddString and use SelectString. The AddString function works and SelectString returns successfully, but it does not show up in the text area of the combobox.
 
Did you solve your problem?
Just checked the forum and have another idea. AddString returns the index of newly added item. Try passing it to SetCurSel() method. Otherwise, it's really strange the item is not shown in text area. Maybe in the code somewhere you change it back?

------------------
When you do it, do it right.
 
The problem is solved. I had to use the UpdateData() function for it to be shown. Thanks all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top