在你的comobobox
意志上设置这些就可以实现你正在寻找的技巧,Combo已启用,但没有人可以更改或输入任何内容,因此Appearance = Enabled,Behavior = Disabled :)
comboBox1.DropDownHeight = 1;
comboBox1.KeyDown += (s, e) => e.Handled = true;
comboBox1.KeyPress += (s, e) => e.Handled = true;
comboBox1.KeyUp += (s, e) => e.Handled = true;
Run Code Online (Sandbox Code Playgroud)
如果由于某种原因你不能使用lambdas,则可以关联跟随处理程序.右键单击 - >如果你有DropDownStyle = DropDown,则必须另外处理粘贴.
//void comboBox1_KeyUp(object sender, KeyEventArgs e)
//{
// e.Handled = true;
//}
//void comboBox1_KeyPress(object sender, KeyPressEventArgs e)
//{
// e.Handled = true;
//}
//void comboBox1_KeyDown(object sender, KeyEventArgs e)
//{
// e.Handled = true;
//}
Run Code Online (Sandbox Code Playgroud)