在datagridView中加入一个combox列,怎么能允许用户输入

2024-12-14 01:20:21
推荐回答(1个)
回答1:

解决办法如下:

private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if (dataGridView1.CurrentCell.ColumnIndex == 3) //这里需要你具体的列索引
{

DataGridViewComboBoxEditingControl editCtrl = e.Control as DataGridViewComboBoxEditingControl;
editCtrl.DropDownStyle = ComboBoxStyle.DropDown; //变为这样的下拉风格
}

}