0
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.

4

1 回答 1

0

我认为你应该使用这样的东西

 var text = dataGridView1.Columns[1].HeaderText;
                TextBox txt = new TextBox();
                txt.Text = text;
于 2013-05-05T02:41:10.933 回答