c# combobox autocomplete like method
Posted
by
Willem T
on Stack Overflow
See other posts from Stack Overflow
or by Willem T
Published on 2012-11-16T10:58:10Z
Indexed on
2012/11/16
10:59 UTC
Read the original article
Hit count: 153
Ihave been looking for an LIKE autocompletion mode. can anyone help me with this.
When i enter a text in the combobox, the database should be asked for the data. all that goes well. But then i want my combobox to behave like the Suggest mode, but it doesn't work.
I Tried this:
cursorPosition = txtNaam.SelectionStart;
string query = "SELECT bedr_naam FROM tblbedrijf WHERE bedr_naam LIKE '%" + txtNaam.Text + "%'";
DataTable table = Global.db.Select(query);
txtNaam.Items.Clear();
for (int i = 0; i < table.Rows.Count; i++)
{
txtNaam.Items.Add(table.Rows[i][0].ToString());
}
Cursor.Current = Cursors.Default;
txtNaam.Select(cursorPosition, 0);
But the behavior that this function creates is off it doesnt work like the suggest mode its a bit buggy.
Can anyone help me to get it working properly
Thanks
© Stack Overflow or respective owner