我已将 EditMode 属性设置为 EditorEnter ,然后单击即可访问该下拉列表。
在gridcellclick上写了代码
If (e.ColumnIndex == 5)
{
SendKeys.SendWait("{F4}")
}
并且还编写了代码
private void comboBox1_Enter(object sender, System.EventArgs e)
{
comboBox1.DroppedDown = true;
}
但结果是一样的。我无法通过单击访问下拉列表。只需点击两下即可打开下拉列表。
更新:
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
ComboBox combo = e.Control as ComboBox;
if (combo != null)
{
combo.Enter -= new EventHandler(combo_Enter);
combo.Enter += new EventHandler(combo_Enter);
}
}
答案 0 :(得分:0)
对我来说很好:
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
ComboBox comboBox = e.Control as ComboBox;
if (comboBox != null)
{
comboBox.Enter -= comboBox_Enter;
comboBox.Enter += comboBox_Enter;
}
}
private void comboBox_Enter(object sender, EventArgs e)
{
((ComboBox)sender).DroppedDown = true;
}