Read only combobox?
How do I make a combobox read only? I remember back when I used VS2005 you could have a read only combobox in the default style. Reason I don't want to use DropDownList is because it looks ugly on forms that don't use a default color. Here is an example.
I want one like in the left of this picture.
Were you can no开发者_运维问答t enter in your own text. But I don't want the style in the first image to the right.
Set the drop down style to DropDownList
and the flatStyle to Flat
:
this.ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
this.comboBox1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
You can select always the element[0]
(if exists) to look like the example you provided.
The Visual Studio combo draws a border OnMouseHover, you can also do this if you want.
Change the drop down style, it's a property.
See: http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.dropdownstyle.aspx
精彩评论