Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Filter your datagrid through text in a combobox/textbox

Filter your datagrid through text in a combobox/textbox

Scheduled Pinned Locked Moved Visual Basic
csharpwpfwcf
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    blonkie
    wrote on last edited by
    #1

    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 :->)

    C 1 Reply Last reply
    0
    • B blonkie

      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 :->)

      C Offline
      C Offline
      C1AllenS
      wrote on last edited by
      #2

      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, Allen

      Allen Smith Software Engineer ComponentOne LLC www.componentone.com

      B 1 Reply Last reply
      0
      • C C1AllenS

        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, Allen

        Allen Smith Software Engineer ComponentOne LLC www.componentone.com

        B Offline
        B Offline
        blonkie
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups