问题
I have ordinary combobox and I want to prevent any changes on it, so I want to make it not show dropdown. Is it possible?
I've tried changing dropDownStyle to simple, but then it shows list of items below.
回答1:
One way to achieve this is to create readonly TextBox over the combo, wirh exact size and font of the combo, so the user possibly will not notice any difference.
回答2:
if you don't want to allow user to do anything with combobox you can use this code in the constructor
public Form1()
{
InitializeComponent();
comboBox1.Enabled = false;
}
else if you want to prevent user from writing anything in the combobox to select the items in combobox you can use this code
{
InitializeComponent();
comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
}
回答3:
If you don't want to allow any changes on the control than I think you should set its Enabled property to false http://msdn.microsoft.com/en-us/library/system.windows.forms.control.enabled.aspx
来源:https://stackoverflow.com/questions/10567331/c-sharp-combobox-without-dropdown