void dataGridView1_EditingControlShowing(object sender,DataGridViewEditingControlShowingEventArgs e)
{
if (dataGridView1.CurrentCell.ColumnIndex == 1)
{
TextBox txt= e.Control as TextBox;
if (dataGridView1.Columns[1].HeaderText.Equals("Header"))
{
if (txt!= null)
{
txt.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
txt.AutoCompleteCustomSource = ..datasource...;
txt.AutoCompleteSource = AutoCompleteSource.CustomSource;
}
}
}
}
当我在第一列开始编辑时,它工作正常。我有不止一个 datagridtextbox 列,因此所有列都可以自动完成。我想防止这种情况,并且必须在dataGridView1.CurrentCell.ColumnIndex == 1
.