I have created a COMBOBOX in my MFC application.
Lets say I have 3 elements inside it: "apples" "bananas" "Type..."
When "apples" and "bananas" are selected don't allow the user to type into the combobox which is achieved by the CBS_DROPDOWNLIST
property of my COMBOBOX definition.
However when " Type... " is selected I want the user to add in a new fruit by typing inside the ComboBox.
So in other words have the ComboBox with the CBS_DROPDOWNLIST
and CBS_DROPDOWN
property depending on the element selected.
Is this possible?
No, a combo box can have only one of CBS_DROPDOWNLIST
, CBS_DROPDOWN
or CBS_SIMPLE
styles, not a combination of them.
You can probably somehow emulate your desired behavior by using the CBS_DROPDOWN
style and having the edit control disabled (enable it when the user selects "Type..." ). The GetComboBoxInfo()
function (or the CB_GETCOMBOBOXINFO
message) returns the handles of the edit and list controls, among other info.
Or else use the CBS_DROPDOWNLIST
style and display a simple dialog-box (with an edit control and OK/Cancel buttons to add an element to the combo-box)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.