I'm writing a GUI in C#, Visual Studio 2008, using the Designer and WinForms. I've got a ComboBox control, and I'd like it to only allow to select from the provided options and not to accept a user-entered string. It doesn't appear to have a ReadOnly property, and disabling it hinders the readability of the control (as well as disallowing user-selection).
            Asked
            
        
        
            Active
            
        
            Viewed 3.5k times
        
    28
            
            
        - 
                    The DropDownStyle property was what I was looking for. Can't believe I overlooked that. – Brock Greman Oct 02 '08 at 15:31
- 
                    3possible duplicate of [How can I make a ComboBox non-editable in .net?](http://stackoverflow.com/questions/85702/how-can-i-make-a-combobox-non-editable-in-net) – nawfal Dec 29 '13 at 02:15
5 Answers
11
            
            
        Set the ComboBox.DropDownStyle property to ComboBoxStyle.DropDownList.
 
    
    
        OregonGhost
        
- 23,359
- 7
- 71
- 108
3
            
            
        Another simple way to go about it.
private void combobox1_KeyPress(object sender, KeyPressEventArgs e)
{
    e.Handled = true;
}
 
    
    
        Isuru
        
- 30,617
- 60
- 187
- 303
 
     
     
     
    