I have a bound dataGridView with an autoComplete combobox column and the autocomplete is working except that am observing one behaviour thats abit irritating.
When i type text in the autocomplete cell for the first time and move to the next cell with the tabKey, my selection is not retained, what ever i selected is cleared and the autocomplete cell is left null. If ii immediately use the left arrow key to return to that autocomplete cell and type in text, what ever i select is retained with out any issues.
So, the problem am having is getting the cell retain my very first initial selection, the only work around now is to Tab to the next cell, then return back to this problematic autoComplete combobox cell and do the typing all all-over. At this point, it works.
Could there be some event i should handle to commit my selected text on cell leave?
Code:
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if (e.Control is ComboBox)
{
((ComboBox)e.Control).DropDownStyle = ComboBoxStyle.DropDown;
((ComboBox)e.Control).AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
((ComboBox)e.Control).AutoCompleteSource = AutoCompleteSource.ListItems;
}
}
Edit: On CellLeave below, value is also returned as null even when i have made a selection.
private void dataGridView1_CellLeave(object sender, DataGridViewCellEventArgs e)
{
var Row = this.dataGridView1.CurrentRow.Index;
string value = this.dataGridView1["itemID", Row].Value.ToString();
}