Hi,
I'm using autocompletion in my datagridview.
this is the code i'm using:
private AutoCompleteStringCollection codeCompletionSource;
private AutoCompleteStringCollection omschrijvingCompletionSource;
this.codeCompletionSource = new AutoCompleteStringCollection();
this.omschrijvingCompletionSource = new AutoCompleteStringCollection();
foreach (DataRow dr in this.database.MagazijnDs.Tables[0].AsEnumerable())
{
this.codeCompletionSource.Add(dr.ItemArray[1].ToString());
this.omschrijvingCompletionSource.Add(dr.ItemArray[2].ToString());
}
private void dgvItems_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if (dgvItems.CurrentCellAddress.X == 1)
{
TextBox txt = e.Control as TextBox;
txt.AutoCompleteCustomSource = this.codeCompletionSource;
txt.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
txt.AutoCompleteSource = AutoCompleteSource.CustomSource;
}
else if (dgvItems.CurrentCellAddress.X == 2)
{
TextBox txt = e.Control as TextBox;
txt.AutoCompleteCustomSource = this.omschrijvingCompletionSource;
txt.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
txt.AutoCompleteSource = AutoCompleteSource.CustomSource;
}
}
Everything seems to be working fine.
The only problem is that the autocompletion isn't applied to the right columns.
Obviously I want the autocompletion applied to the second and third cell in the datagridviewrows.
The second is working but the third is not. The autocompletion of the third cell does get applied to the fourth, fift, sixt and seventh cell.
Any suggestions?
Best regards,
YMaod