【发布时间】:2015-03-05 17:05:18
【问题描述】:
datagridview 中的组合框有问题。好的,让我解释一下。 在我的表单中,我有文本框、datagridview 和组合框(添加到 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。 请告诉我原因,并给出解决方案。
【问题讨论】:
-
你在 SelectedIndexChanged 事件中做了什么?我们可能需要查看该代码。为什么要将 ComboBox 添加到 DataGridView 控件?有一个 DataGridViewComboBoxCell 来处理。
标签: c# winforms datagridview combobox