问题描述
大家好,
首先,我想感谢您在本网站上找到的精彩文章!
好吧,我遇到绑定源的过滤方法有问题。
我的想法是使用组合框来选择过滤器所在的列方法是
去寻找插入文本框的文字。
这是我的猜测:
Hi everyone,
First of all I would like to thank you for the great articles we can find on this web site!
Well, I''m having a problem with the filter method of the binding source.
My idea is to use a combo box to select the column where the filter method is
going to look for the text inserted in a text box.
Here is my guess:
Private Sub TextBox12_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox12.TextChanged
Me.InventarioCompletoBindingSource.Filter = "(ComboBox1.Text) LIKE '" & TextBox12.Text & "%'"
End Sub
这给了我这个错误:
This gives me this error:
The column Combobox1 can't be found
有什么想法吗?
谢谢你提前
Any ideas?
Thank you in advance
推荐答案
Private Sub TextBox12_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox12.TextChanged
Me.InventarioCompletoBindingSource.Filter = "(ComboBox1.SelectedItem.ToString()) LIKE '" & TextBox12.Text & "%'"
End Sub
Private Sub TextBox12_TextChanged(ByVal sender As System.Object,ByVal e As System.EventArgs)处理TextBox12.TextChanged
如果ComboBox1.SelectedItem = Nothing那么
Me.InventarioCompletoBindingSource.Filter =COD1 LIKE''& TextBox12.Text& %''或EQUIPO LIKE''& TextBox12.Text& %''或MARCA LIKE''& TextBox12.Text& %''或MODELO LIKE''& TextBox12.Text& %''或SER SER LIKE''& TextBox12.Text& %''或UBICACION LIKE''& TextBox12.Text& %''或ZONA LIKE''& TextBox12.Text& %''或LUGAR LIKE''& TextBox12.Text& %''或ESTADO LIKE''& TextBox12.Text& %''
ElseIf ComboBox1.SelectedItem.ToString =Equipo然后
Me.InventarioCompletoBindingSource.Filter =EQUIPO LIKE''& TextBox12.Text& %''
ElseIf ComboBox1.SelectedItem.ToString =Marca然后
Me.InventarioCompletoBindingSource.Filter =MARCA LIKE''& TextBox12.Text& %''
ElseIf ComboBox1.SelectedItem.ToString =Modelo然后
Me.InventarioCompletoBindingSource.Filter =MODELO LIKE''& TextBox12.Text& %''
ElseIf ComboBox1.SelectedItem.ToString =Serie然后
Me.InventarioCompletoBindingSource.Filter =SERIE LIKE''& TextBox12.Text& %''
ElseIf ComboBox1.SelectedItem.ToString =Ubicacion然后
Me.InventarioCompletoBindingSource.Filter =UBICACION LIKE''& TextBox12.Text& %''
ElseIf ComboBox1.SelectedItem.ToString =Zona然后
Me.InventarioCompletoBindingSource.Filter =ZONA LIKE''& TextBox12.Text& %''
ElseIf ComboBox1.SelectedItem.ToString =Lugar然后
Me.InventarioCompletoBindingSource.Filter =LUGAR LIKE''& TextBox12.Text& %''
ElseIf ComboBox1.SelectedItem.ToString =Estado然后
Me.InventarioCompletoBindingSource.Filter =ESTADO LIKE''& TextBox12.Text& %''
ElseIf ComboBox1.SelectedItem.ToString =Todos然后
Me.InventarioCompletoBindingSource.Filter =COD1 LIKE''& TextBox12.Text& %''或EQUIPO LIKE''& TextBox12.Text& %''或MARCA LIKE''& TextBox12.Text& %''或MODELO LIKE''& TextBox12.Text& %''或SER SER LIKE''& TextBox12.Text& %''或UBICACION LIKE''& TextBox12.Text& %''或ZONA LIKE''& TextBox12.Text& %''或LUGAR LIKE''& TextBox12.Text& %''或ESTADO LIKE''& TextBox12.Text& %''
结束如果
End Sub
Private Sub TextBox12_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox12.TextChanged
If ComboBox1.SelectedItem = Nothing Then
Me.InventarioCompletoBindingSource.Filter = "COD1 LIKE ''" & TextBox12.Text & "%'' OR EQUIPO LIKE ''" & TextBox12.Text & "%'' OR MARCA LIKE ''" & TextBox12.Text & "%'' OR MODELO LIKE ''" & TextBox12.Text & "%'' OR SERIE LIKE ''" & TextBox12.Text & "%'' OR UBICACION LIKE ''" & TextBox12.Text & "%'' OR ZONA LIKE ''" & TextBox12.Text & "%'' OR LUGAR LIKE ''" & TextBox12.Text & "%''OR ESTADO LIKE ''" & TextBox12.Text & "%''"
ElseIf ComboBox1.SelectedItem.ToString = "Equipo" Then
Me.InventarioCompletoBindingSource.Filter = "EQUIPO LIKE ''" & TextBox12.Text & "%''"
ElseIf ComboBox1.SelectedItem.ToString = "Marca" Then
Me.InventarioCompletoBindingSource.Filter = "MARCA LIKE ''" & TextBox12.Text & "%''"
ElseIf ComboBox1.SelectedItem.ToString = "Modelo" Then
Me.InventarioCompletoBindingSource.Filter = "MODELO LIKE ''" & TextBox12.Text & "%''"
ElseIf ComboBox1.SelectedItem.ToString = "Serie" Then
Me.InventarioCompletoBindingSource.Filter = "SERIE LIKE ''" & TextBox12.Text & "%''"
ElseIf ComboBox1.SelectedItem.ToString = "Ubicacion" Then
Me.InventarioCompletoBindingSource.Filter = "UBICACION LIKE ''" & TextBox12.Text & "%''"
ElseIf ComboBox1.SelectedItem.ToString = "Zona" Then
Me.InventarioCompletoBindingSource.Filter = "ZONA LIKE ''" & TextBox12.Text & "%''"
ElseIf ComboBox1.SelectedItem.ToString = "Lugar" Then
Me.InventarioCompletoBindingSource.Filter = "LUGAR LIKE ''" & TextBox12.Text & "%''"
ElseIf ComboBox1.SelectedItem.ToString = "Estado" Then
Me.InventarioCompletoBindingSource.Filter = "ESTADO LIKE ''" & TextBox12.Text & "%''"
ElseIf ComboBox1.SelectedItem.ToString = "Todos" Then
Me.InventarioCompletoBindingSource.Filter = "COD1 LIKE ''" & TextBox12.Text & "%'' OR EQUIPO LIKE ''" & TextBox12.Text & "%'' OR MARCA LIKE ''" & TextBox12.Text & "%'' OR MODELO LIKE ''" & TextBox12.Text & "%'' OR SERIE LIKE ''" & TextBox12.Text & "%'' OR UBICACION LIKE ''" & TextBox12.Text & "%'' OR ZONA LIKE ''" & TextBox12.Text & "%'' OR LUGAR LIKE ''" & TextBox12.Text & "%''OR ESTADO LIKE ''" & TextBox12.Text & "%''"
End If
End Sub
这篇关于使用ComboBox在绑定源筛选器中选择DataColumn的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!