Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Readonly ComboBox in WinForms

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).

like image 834
Brock Greman Avatar asked Oct 02 '08 15:10

Brock Greman


People also ask

How do you make a ComboBox readonly in Windows Forms?

You'll need to rebuild the project after you add the ReadOnlyComboProvider class. Then simply drag one of these from the toolbox onto your form and set the properties via a property window or via code. Here's the code example to make the combobox readonly via code: Note: This works similiarly to tooltips...

How do you make a combo box Uneditable?

To make the text portion of a ComboBox non-editable, set the DropDownStyle property to "DropDownList". The ComboBox is now essentially select-only for the user. You can do this in the Visual Studio designer, or in C# like this: stateComboBox.

How to set ComboBox Readonly in vb net?

Set the DropDownStyle property of the combobox to DropDownList . This will allow only items in the list to be selected and will not allow any free-form user input.


1 Answers

Set DropDownStyle to "DropDownList"

like image 79
Phillip Wells Avatar answered Sep 20 '22 13:09

Phillip Wells