datagridview已经绑定了数据库的数据,
现在想做一个模糊搜索, 
如果想搜索Cmptname, 我可以
dbo_a014CmptBindingSource.Filter = "Cmptname like '%" + txtSearch.Text + "%'";
现在我想搜索ForestName,但是这个forestname只有Forestid在这个表, 我是通过combobox把Forestname显示在datagridview,我怎么才能搜索到ForestName呢?如果我用搜索Cmptname的方法去搜索ForestName, 只能用Forestid,所以请大家帮我想想办法, 谢谢了。

解决方案 »

  1.   

    绑定combobox时,把Forestname绑定到DisplayMember上,Forestid绑定到ValueMember上,选中Combobox时可以得到具体选中的Forestid值,然后根据Forestid过滤datagridview
      

  2.   

    我就是这么做的, 但是问题是
    datagridview只能看见Forestname,
    所以想通过name做搜索, id是看不见,
    问题是filter又只能通过id。。
      

  3.   

    重新再写数据绑定, 就是用tableadapter,然后有条件的选择
      

  4.   

    DataTable table=datagridview.DataSource as DataTable;
    然后在table里查询就是了