日期:2014-05-17 浏览次数:21211 次
//先绑定数据到ComBoBox
DataTable data = new DataTable();//定义成全局
data.Columns.Add("column1", typeof(int));
data.Columns.Add("column2", typeof(string));
DataRow dr1 = data.NewRow();
dr1["column1"] = 1;
dr1["column2"] = "NO.1";
DataRow dr2 = data.NewRow();
dr2["column1"] = 2;
dr2["column2"] = "NO.2";
DataRow dr3 = data.NewRow();
dr3["column1"] = 3;
dr3["column2"] = "NO.3";
data.Rows.Add(dr1);
data.Rows.Add(dr2);
data.Rows.Add(dr3);
this.comboBox1.DataSource = data;
this.comboBox1.DisplayMember = "column2";
private void textBox1_TextChanged(object sender, EventArgs e)
{
string sn = "column2 like '%" + this.textBox5.Text.Trim() + "%'";
DataRow[] dr = data.Select(sn);
foreach (DataRow d in dr)
{
this.comboBox1.DataSource = d.ItemArray.ToList();
&nb