Filter your datagrid through text in a combobox/textbox
-
Yo, I have an datagrid where I want to filter my data I got. The filter I want to use is the text inside an combobox or textbox (it doesn't matter) This is the code I already have Private Sub cmbPO_textChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbPO.SelectedValueChanged Me.TblLijstBindingSource.Position = Me.cmbPO.SelectedIndex End Sub Where: cmbPO = combobox tblLijstBindingSource = binding source This doesn't works like I want it, I want to see just the record I've insert in the combobox. But if this is to hard to do, it may just jump to that record. Thanks (Plz keep in VB.NET and do not throw code of C# or such a languages :->)
-
Yo, I have an datagrid where I want to filter my data I got. The filter I want to use is the text inside an combobox or textbox (it doesn't matter) This is the code I already have Private Sub cmbPO_textChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbPO.SelectedValueChanged Me.TblLijstBindingSource.Position = Me.cmbPO.SelectedIndex End Sub Where: cmbPO = combobox tblLijstBindingSource = binding source This doesn't works like I want it, I want to see just the record I've insert in the combobox. But if this is to hard to do, it may just jump to that record. Thanks (Plz keep in VB.NET and do not throw code of C# or such a languages :->)
Hello, To achieve this, you would have to use the filter property for the binding source. You will have to specifically put the filter condition on the field whose value you will enter in the Text box. You can use the following code in the TextChanged event of the Combobox or the Text Box:
Private Sub ComboBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.TextChanged Me.TblLijstBindingSource.Filter = " ='" & Me.ComboBox1.Text & "'" End Sub
I believe this should help. Regards, AllenAllen Smith Software Engineer ComponentOne LLC www.componentone.com
-
Hello, To achieve this, you would have to use the filter property for the binding source. You will have to specifically put the filter condition on the field whose value you will enter in the Text box. You can use the following code in the TextChanged event of the Combobox or the Text Box:
Private Sub ComboBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.TextChanged Me.TblLijstBindingSource.Filter = " ='" & Me.ComboBox1.Text & "'" End Sub
I believe this should help. Regards, AllenAllen Smith Software Engineer ComponentOne LLC www.componentone.com
Thanks for your help but still got an error :
Syntax error: Missing operand before '=' operator.
Btw how do you search for a value who is in a datagrid who is dynamic created. I mean how can you bind a dataset to the datagrid, and not the datagrid to the dataset. Thanks