title: DataGridView Filtering Using BindingSource (Of CustomClassObjects)
body: <p>I want to filter through my DataGridView data. My DataGridView's DataSource is bound to a <code>BindingSource</code>. The BindingSource contains a list of objects from my <code>clsBillHeader</code> class. </p>
  
  <p>Here is the first bit of code:</p>
  
  <pre><code>Dim bSource As New BindingSource
  bSource.DataSource = clsBillHeader.GetAll()
  dgvBills.DataSource = bSource
  bSource.Filter = "JobNumber Like '100%'" //Filter doesn't actually work
  </code></pre>
  
  <p><strong>GetAll()</strong></p>
  
  <pre><code>Public Shared Function GetAll() As List(Of clsBillHeader)
      Dim mycn As New SqlConnection(connection)
      Dim mycmd As New SqlCommand("SELECT * FROM Headers", mycn)
      mycn.Open()
      Dim myreader As SqlDataReader = mycmd.ExecuteReader
      Dim myList As New List(Of clsBillHeader)
      While myreader.Read
          Dim item As New clsBillHeader()
          SetByReader(myreader, item) //Sets all values correctly (such as forein keys)
          myList.Add(item)
      End While
      mycn.Close()
      Return myList
  End Function
  </code></pre>
  
  <p>This successfully returns all my values needed as you can see in this screenshot:</p>
  
  <p><img src="https://i.stack.imgur.com/c93vq.png" alt="BindingSource"></p>
  
  <hr>
  
  <p>The problem is it doesn't filter through anything ... my <code>JobNumber Like '100%'</code> doesn't seem to be filtering at all. As seen below:</p>
  
  <p><img src="https://i.stack.imgur.com/NlxZQ.png" alt="Unwanted Results"></p>
  
  <p>I should just be getting the first two numbers but it returns everything else ... </p>
  
  <p><strong>Why am I not using DataView to use filtering?</strong></p>
  
  <p>Well, DataView would cause me to use a DataTable that is directly bound to the SQL table. Some values in my table are foreign keys and would need to be transformed into something more meaningful than integers.</p>
  
  <p>Ex: <code>FK_Author = 1</code> would be the value in the DataTable. Instead, I use my SetByReader to transform it into <code>Author = "Alex"</code>. That's why I want to use a BindingSource.</p>
  
  <p>All I need is to filter through a DataGridView bound to a class of <code>clsBillHeaders</code>. Has anyone had the same problem?</p>
  
  <h2>EDIT</h2>
  
  <p>Take a look at this screenshot. Apparently it doesn't support Filtering ...</p>
  
  <p><img src="https://i.stack.imgur.com/oXKeB.png" alt="NoFilter Support"></p>
  
  <p>Why does my BindingSource variable have this by default?</p>