在C#Windows应用程序的组合框中填充过滤器数据 [英] populated filter data in combo box in C# windows application
本文介绍了在C#Windows应用程序的组合框中填充过滤器数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
我目前正在使用MS Access 2003 DB作为后端的C#Windows应用程序,我正在尝试以组合框的形式获取过滤器数据,例如如果我输入0,那么它应该在组合框中显示所有0个开始的数据,但它没有" t以及组合框的哪个事件将在下面出现,我将显示代码
Hi All
I am currently working on C# windows application where I am using MS Access 2003 DB as back end I am trying to get filter data in combo box as example If I put 0 so it should show all 0 started data in the combo box but it doesn''t and also under which event of the combo box it will come below I show Code
private void comboBox_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
comboBox.Refresh();
string str = "SELECT BookID FROM BookMaster WHERE BookID like ''%" + comboBox.Text + "%''";
OleDbCommand cmd = new OleDbCommand(str, conn);
OleDbDataAdapter da = new OleDbDataAdapter();
da.SelectCommand = cmd;
DataTable dt = new DataTable();
da.Fill(dt);
for (int i = 0; i < dt.Rows.Count; i++)
{
comboBox.Items.Add(dt.Rows[i]["BookID"]);
}
}
但是并没有达到预期
谢谢&问候
Indrajit Dasgupta
but it is not coming as expectation
Thanks & Regards
Indrajit Dasgupta
推荐答案
检查查询返回的值,您的数据集不为空. 谢谢
--RA
Check your Query returns values, your DataSet is not empty..
Thanks
--RA
这篇关于在C#Windows应用程序的组合框中填充过滤器数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文