Click here to Skip to main content
15,890,947 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
What exactly does the IsReadOnly attribute do on the ComboBox?
I would expect it should not allow you to change the value or select an item from the drop down list, yet you can.

Is there a way to make it truly read only?
Posted
Updated 30-Jul-13 21:36pm
v2
Comments
Richard MacCutchan 31-Jul-13 3:48am    
I don't see any reference to this property in the documentation.

Quote IsReadOnly[^]:
Gets or sets a value that enables selection-only mode, in which the contents of the combo box are selectable but not editable.
The property determine whether the edit box of the combo box can be used.
The documentation[^] contains a table which specifies what you can and cannot to when the property is true or false.

If you want the make the combo box control completely read only set the IsEnabled[^] property to false.
 
Share this answer
 
CComboBox::ShowDropDown is a good idea to hide the DropDown, so the User can't select any Item
 
Share this answer
 
If you want to make combo-box's edit control read only, then change combo-box's "Type" to "Drop List". If you have selected "Type" as "Drop Down", then edit control remains editable. You should do all this as "Design Time" only. At run time these properties do not change.

To change these properties at run-time:
First get Combo-box information by "GetComboBoxInfo()".
Obtain handle of its edit control(hwndItem member of COMBOBOXINFO structure).
Set edit control property to read only by "SetReadOnly()".
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900