Witam.
Próbuję zrobić coś takiego :
Czyli:
DataGridView i chcę aby po wpisaniu jakiegoś ciągu jednej z kolumn pokazało "podpowiedzi" które będą wynikiem zapytania w stylu
string.Format("SELECT nazwa FROM tabela WHERE nazwa LIKE '%{0}%'", CellValue.Replace(' ', '%'))
.
Źródło AutoComplete
uzupełniam w taki sposób:
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
TextBox autoText = e.Control as TextBox;
if (autoText != null)
{
SqlCommand SQLCmd = new SqlCommand("SELECT nazwa FROM tabela ", SQLC);
SqlDataReader SQLDR = SQLCmd.ExecuteReader();
AutoCompleteStringCollection DataCollection = new AutoCompleteStringCollection();
while (SQLDR.Read())
{
DataCollection.Add(SQLDR[0].ToString());
}
SQLDR.Close();
autoText.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
autoText.AutoCompleteSource = AutoCompleteSource.CustomSource;
autoText.AutoCompleteCustomSource = DataCollection;
}
}
Jednak nie mam pomysłu jak przekonać go wyszukiwania po fragmentach tekstu a nie od początku.