更新
感谢Hanlet解决问题,语法如下:
source1.Filter = "[Column] LIKE '%" & TextBox1.Text & "%'"
对于任何感兴趣的人,这是在多个标准上执行上述操作的语法:
source1.Filter = "[Column1] LIKE '%" & TextBox1.Text & "%' OR [Column2] LIKE '%" & TextBox1.Text & "%'"
我目前有代码来过滤我的数据源,其中“客户名称”列等于文本框中的文字。
但是,我想要的是一个类似于sql中的LIKE函数的过滤器,因此如果客户名称为“John”并且用户在文本框中输入“Jo”,它将过滤所有姓名为的客户喜欢/包含'Jo'
这是当前的过滤器代码(如果您希望代码显示数据是如何绑定的那样):
Dim source1 As New BindingSource()
source1.Filter = "[Customer Name] = '" & TextBox1.Text & "'"
dTableMain.Refresh()
感谢您的帮助!
答案 0 :(得分:1)
我过去做过类似的事情。这是一般语法:
' The searchString is searched for in both the Cost Center field AND the Code field
BindingSource.Filter = "[col1] like " & searchString & " OR [col2] like " & searchString
在你的情况下,它将是:
source1.Filter = "[Customer Name] like " & TextBox1.Text
希望它有所帮助!