Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Winforms Combobox - do not allow user to edit items

Tags:

This is probably something simple. The winforms combobox items by default can be edited by the user, how to disable this?

like image 660
Bruce Avatar asked Sep 26 '11 12:09

Bruce


People also ask

How do I make my ComboBox not editable?

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 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 I make my ComboBox read only?

Just change the DropDownStyle to DropDownList . Or if you want it completely read only you can set Enabled = false , or if you don't like the look of that I sometimes have two controls, one readonly textbox and one combobox and then hide the combo and show the textbox if it should be completely readonly and vice versa.

How do I disable input on ComboBox?

1. Set the Combobox dropdownstyle property to simple and give it a new height in the size property to stop all items from showing. After doing this the control looks like a textbox.


1 Answers

Set DropDownStyle = DropDownList.

like image 150
Alex F Avatar answered Sep 18 '22 17:09

Alex F