Answers:
若要使ComboBox的文本部分不可编辑,请将DropDownStyle属性设置为“ DropDownList”。现在,ComboBox基本上只为用户选择。您可以在Visual Studio设计器或C#中执行以下操作:
stateComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
链接到MSDN上ComboBox DropDownStyle属性的文档。
COMBOBOXID.DropDownStyle = ComboBoxStyle.DropDownList;
要在选择后继续在输入中显示数据,请执行以下操作:
VB.NET
Private Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
e.Handled = True
End Sub
C#
Private void ComboBox1_KeyPress(object sender, KeyPressEventArgs e)
{
e.Handled = true;
}
Text
编程方式更新属性,而是使用它来显示默认消息,该属性为ComboBox.SelectedIndex = -1;