日期:2014-05-17  浏览次数:20638 次

c# winform 中键盘操作选中combobox中的内容
实现如下操作,不用鼠标,只用键盘操作

第一步:按enter键后出现combobox的选项
第二步:通过上下键选择其中的选项
第三步:再按enter键使选择的项显示
第四步:按enter键跳转到另外一个textbox中

combobox  选择内容 不用鼠标 键盘操作

------解决方案--------------------
将DropDownStyle设为dropdownlist,关于光标跳转的你自己去处理

private void comboBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter 
------解决方案--------------------
 e.KeyCode == Keys.Return)
            {
                if (!comboBox1.DroppedDown)
                {
                    comboBox1.DroppedDown = true;
                    e.Handled = true;
                }
            }
        }