Hi P.S., You'd better still handle EditingControlShowing event to do the work. But you need to set that only once. Look at the following code. public partial class Form1 : Form { private bool autoCompleteSet; public Form1() { InitializeComponent(); autoCompleteSet = false; dataGridView1.Columns.Add("Column1", "Column1"); dataGridView1.EditingControlShowing += new DataGridViewEditingControlShowingEventHandler(dataGridView1_EditingControlShowing); } void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (!autoCompleteSet) { TextBox txtBox = e.Control as TextBox; if (txtBox != null) { txtBox.AutoCompleteMode = AutoCompleteMode.Suggest; txtBox.AutoCompleteSource = AutoCompleteSource.CustomSource; txtBox.AutoCompleteCustomSource.Add("abcde"); txtBox.AutoCompleteCustomSource.Add("abdce"); txtBox.AutoCompleteCustomSource.Add("bcade"); autoCompleteSet = true; } } } } In the form, there is an autoCompleteSet member, it is set to false at first. When you edit the cell, autocomplete items will be added and autoCompleteSet member will be set to true. So the next time, it won't add these items again. I think this can be a good solution for you. Sincerely, Kira Qian Please mark the replies as answers if they help and unmark if they don't.- Marked As Answer byKira QianMSFT, ModeratorMonday, August 10, 2009 8:21 AM
-
|