Board index » cppbuilder » probably another stupid question on ComboBoxes
|
mickey
CBuilder Developer |
|
mickey
CBuilder Developer |
probably another stupid question on ComboBoxes2003-09-22 01:21:37 PM cppbuilder30 hello everyone! :) i was wondering if there's any way for me to set a TComboBox's style property to csDropDownList but still be able to set it's Text property? i want to make the text property of the combobox readonly. and i also want to set it to a string that may or may not be included in the combobox's items. this way i can provide a default value (even if it is not included in the items). i would really, really appreciate any help. thanks. |
| Remy Lebeau (TeamB)
CBuilder Developer |
2003-09-22 01:48:47 PM
Re:probably another stupid question on ComboBoxes
"mickey" < XXXX@XXXXX.COM >wrote in message
Quotei was wondering if there's any way for me to set a TComboBox's style csDropDownList's design is that it does not allow the user to type in a value manually, but must use the drop-down list only. Quoteand i also want to set it to a string that may or may not be included in Quotethis way i can provide a default value (even if it is not included in the What's wrong with simply testing the ItemIndex for -1 when you go to retreive the selected item, and then using a default value in your code when appropriate? AnsiString value; int index = ComboBox1->ItemIndex; if( index>-1 ) value = ComboBox1->Items->Strings[index]; else value = "some default value"; Gambit |
| Darren Stone
CBuilder Developer |
2003-09-22 02:55:13 PM
Re:probably another stupid question on ComboBoxes
mickey < XXXX@XXXXX.COM >wrote:
Quote
comboBox->Items->Assign(myCars); comboBox->Items->Insert(0, "Select a car..."); comboBox->ItemIndex = 0; The only drawback is that the default text will appear in the drop down list. (But that shouldn't be an issue since lots of ComboBoxes work like that) -- darren {smallsort} |
| mickey
CBuilder Developer |
2003-09-22 03:12:08 PM
Re:probably another stupid question on ComboBoxesQuoteWhy not just have the first item in the list be the default text? the default text that i set may or may not be one of the items. if this is impossible, then i believe i have to resort to my other choice: plead to my trainor. hehehe. :) |
| Remy Lebeau (TeamB)
CBuilder Developer |
2003-09-22 05:01:51 PM
Re:probably another stupid question on ComboBoxes
"mickey" < XXXX@XXXXX.COM >wrote in message
Quotewhat i really wanted to do is no edit field available to set any Text for. Period. You'll just have to do something else with your UI to get around it. Gambit |
| Remy Lebeau (TeamB)
CBuilder Developer |
2003-09-22 05:03:04 PM
Re:probably another stupid question on ComboBoxes
"mickey" < XXXX@XXXXX.COM >wrote in message
Quoteoh! how i would wish i could do that! |
