private void dataGridViewSales_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if (this.dataGridViewSales.CurrentCell.ColumnIndex == 1)
{
ComboBox c = e.Control as ComboBox;
((ComboBox)c).AutoCompleteSource = AutoCompleteSource.ListItems;
((ComboBox)c).AutoCompleteMode = AutoCompleteMode.SuggestAppend;
((ComboBox)c).DropDownStyle = ComboBoxStyle.DropDown;
}
}
使用上面的代码,我遇到了一个问题,在从自动完成组合框中进行选择后,当我通过按 Tab 键退出组合框单元格时,我失去了选择。有时,选择被保留,有时选择被清除,它有点随机发生。