public AutoCompleteStringCollection AutoCompleteLoad() { AutoCompleteStringCollection str = new AutoCompleteStringCollection(); foreach (DataRow row in dt.Rows) { str.Add(Convert.ToString(row[1])); } return str; } private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { int column = dataGridView1.CurrentCell.ColumnIndex; string headerText = dataGridView1.Columns[1].HeaderText; if (headerText.Equals("pro")) { TextBox tb = e.Control as TextBox; if (tb != null) { tb.AutoCompleteMode = AutoCompleteMode.SuggestAppend; tb.AutoCompleteCustomSource = AutoCompleteLoad(); tb.AutoCompleteSource = AutoCompleteSource.CustomSource; } } }
Quote:Your if condition is just checking if the user has currently selected the third column. Do you want to make all that column editable? or just one cell in the currently selected row? How is the edit triggered by another button off the form? In this case when the edit becomes active any cell could be selected? You will need to index into the correct column and set it to have the autocomplete on.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)