组合框上/下箭头键在datagridview winforms中不触发
本文关键字:winforms datagridview 组合 | 更新日期: 2024-10-23 17:03:55
我在datagridview中的组合框有问题。好的,让我来解释一下。在我的表单中,我有文本框、数据网格视图和组合框(添加到数据网格视图中的单元格)。
dt.Columns.Add("col1", typeof(int));
dt.Columns.Add("clo2", typeof(string));
dt.Columns.Add("col3", typeof(string));
dataGridView1.DataSource = dt;
dataGridView1.Controls.Add(comboBox1);
开始我把焦点放在文本框上,然后按Tab键,事件CellEnter被触发。
private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView1.CurrentCell.ColumnIndex == 0)
{
comboBox1_SelectedIndexChanged(null, null);
comboBox1.Focus();
}
}
在第一行中,我看到组合框是焦点,但我不能使用向上/向下箭头键来更改selectedIndex。请告诉我为什么,并给出解决方案。
兄弟,您正在将一个combobox类控件添加到另一个控件datagridview中,请尝试使用datagridview comboxcell,并详细说明您想要实现的问题?