hi every body i work with gridview there is acombox in the gridview which autocomplete it works fine but after choose the value and leave to the next colum the value get clear this my code
public AutoCompleteStringCollection AutoCompleteLoad() { AutoCompleteStringCollection str = new AutoCompleteStringCollection(); foreach (DataRow row in dt.Rows) { str.Add(Convert.ToString(row[1])); } return str; } private void Alaa_Load(object sender, EventArgs e) { this.dataGridView1.CellValidated += new DataGridViewCellEventHandler(dataGridView1_CellValidated); dataGridView1.RowPostPaint += dataGridView1_RowPostPaint; } private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { string titleText = dataGridView1.Columns[2].HeaderText; if (titleText.Equals("proname")) { ComboBox cbo = e.Control as ComboBox; if (cbo != null) { cbo.DropDownStyle = ComboBoxStyle.DropDown; cbo.AutoCompleteMode = AutoCompleteMode.SuggestAppend; cbo.AutoCompleteCustomSource = AutoCompleteLoad(); cbo.AutoCompleteSource = AutoCompleteSource.CustomSource; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)