我有一个和DropDownStyle = ComboBoxStyle.Simple的DataGridViewComboBoxColumn
如何强制下拉菜单在击键时展开?
我已经尝试将((ComboBox)?).DroppedDown = true;放在几个地方,但没有解决方案
发布于 2012-07-23 06:26:50
下面的代码片段应该可以工作:
//If no row/cell selected, select an appropriate row/cell
dataGridView1.Rows[0].Selected = true;
dataGridView1.Rows[0].Cells[0].Selected = true;
//Start edit mode or otherwise EditingControl property will return null
dataGridView1.BeginEdit(true);
var comboBox = dataGridView1.EditingControl as DataGridViewComboBoxEditingControl;
if (comboBox != null)
{
comboBox.DroppedDown = true;
}需要注意的是,您的组合框中必须有项目,可以通过绑定输入,也可以手动输入。
https://stackoverflow.com/questions/11604009
复制相似问题