【问题标题】:Combobox Arrow Up/down key do not fire in datagridview winforms组合框箭头向上/向下键不会在 datagridview winforms 中触发
【发布时间】: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


【解决方案1】:

兄弟,您正在将组合框类控件添加到其他控件 datagridview 尝试使用 datagridviewcomboboxcell 并详细说明您的问题是什么?

【讨论】:

    猜你喜欢
    • 2019-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-21
    相关资源
    最近更新 更多