dualshck012
Active member
I have a combobox control, and it contains items:
123 abc
12 ab
abc 123
def
ghm 123
I want when i write "123" into combobox, then dropdown list will show:
123 abc
abc 123
ghm 123
I already have a code but I'm getting this error message:
An unhandled exception of type 'System.Data.SyntaxErrorException' occurred in System.Data.dll
Additional information: Syntax error: Missing operand after 'diagtext' operator.
123 abc
12 ab
abc 123
def
ghm 123
I want when i write "123" into combobox, then dropdown list will show:
123 abc
abc 123
ghm 123
I already have a code but I'm getting this error message:
An unhandled exception of type 'System.Data.SyntaxErrorException' occurred in System.Data.dll
Additional information: Syntax error: Missing operand after 'diagtext' operator.
C#:
DataTable AllNames = new DataTable();
private void Cward_combox_KeyPress(object sender, KeyPressEventArgs e)
{
string name = string.Format("{0}{1}", Cward_combox.Text, e.KeyChar.ToString());
DataRow[] rows = table.Select(string.Format("select diagtext from hencdiag where diagtext LIKE '%{0}%'", name));
DataTable filteredTable = AllNames.Clone();
foreach (DataRow r in rows)
filteredTable.ImportRow(r);
Cward_combox.DataSource = null;
Cward_combox.DataSource = filteredTable.DefaultView;
Cward_combox.DisplayMember = "diagtext";
}