【问题标题】:BindingSource.Filter: Combining Multiple Filters C# WinformsBindingSource.Filter:组合多个过滤器 C# Winforms
【发布时间】:2014-06-23 07:42:54
【问题描述】:

我正在编写一个连接到 Access 数据库的程序。我有 3 个我正在尝试组合的搜索条件。其中两个过滤器来自复选框,而第三个是搜索框。这三个单独工作很好。但是,当尝试连接过滤器时,它似乎只能识别“CheckedSListFilter”。我已经测试了连接字符串的多次迭代,没有任何运气。我希望这只是一个语法问题。谢谢你的帮助。

        string SFilter = CheckedSListFilter();// method returns string "S = 'w1' OR S = 'w2' OR S = 'w3'"
        string PFilter = CheckedPStatusFilter();//method returns string "PA = 'True' OR "PB = 'True'"
        string CFilter = comboBox_SearchFields.Text;
        string filter = CFilter + " LIKE '" + "*" + textBox_search.Text + "*" + "'";//returns "R LIKE '*g*'"

                BindingSource bs = this.projectBindingSource;
                bs.Filter =  filter+" AND "+"("+PFilter +" OR "+SFilter+")";

【问题讨论】:

    标签: c# winforms ms-access-2010 bindingsource


    【解决方案1】:

    我自己解决了这个问题。操作顺序让我绊倒了。最终做了这样的事情: bs.Filter = "("+SFilter+")"+" AND "+"("+PFilter+")"+" AND "+"("+PFilter+")"; 现在一切正常。

    【讨论】:

      猜你喜欢
      • 2011-10-08
      • 2021-04-24
      • 1970-01-01
      • 1970-01-01
      • 2021-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多