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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Un-editable ComboBox (DropDownList) problems...

Status
Not open for further replies.

Cobra220

Programmer
Dec 17, 2006
8
US
I'm rather new to C++ but not to programming (up until this morning, I didn't know how to work Visual C++ '05). In an application I'm working on, I need a comboBox that is un-editable. I figured out that I do that by changing the dropDownStyle to dropDownList. It works fine except one thing. When the application runs, the 'title' of the comboBox is blank. When I select an option, the blank 'title' is no longer available. It seems like the only way to set the title text of a comboBox is to have it editable, which I cannot use. I'm missing something extremely simple, aren't I?

Happy holidays!
-David
 
Add an empty selection option to the list. Or if you need to change it programmatically, try setting the selected index to -1.

------------------
When you do it, do it right.
 
Changing the selectedIndex to 0 worked...one problem, though. When I debug the program and run it, sometimes the line changing the selectedIndex to 0 gets deleted!

Is this a bug in Visual C++ or an error on my part?
 
What do you mean by "the line gets deleted" ? deleted in source file? or where?

------------------
When you do it, do it right.
 
Here is what happened. I made two ComboBoxes with the Microsoft Visual C++ form maker. I set them as uneditable. I wanted to change the selected index to the first text, instead of a blank space so I manually added code into the form.h file to set the selected index to what I wanted. When I first went to debug/run the program, it worked fine. After trying to debug/run it again, the code mysteriously wasn't there anymore...
Its working fine now, but still, I don't think it should have happened.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top