title: Filtering binding source
body: <p>This should be easy but I am having a headbanging of a time trying to get this to work! I have done a search and tried all most EVERY SINGLE ONE. Nothing works. I have a datagrid with a binding source. A user will type text into a textbox and the grid is SUPPOSED to change to only show records that contain what user typed in the name. Simple right? NOPE! Not for me! What am I doing wrong? Code below.</p>
  
  <pre><code>Private Sub SearchButton_Click(sender As Object, e As EventArgs) Handles SearchButton.Click
      Dim Found As Boolean = False
      Dim StringToSearch As String = ""
      Dim ValueToSearchFor As String = "%" &amp; SearchTextBox.Text.Trim.ToLower &amp; "%"
      Dim CurrentRowIndex As Integer = 0
  
      Try
  
          If ReferencesGrid.Rows.Count = 0 Then
              CurrentRowIndex = 0
          Else
              CurrentRowIndex = ReferencesGrid.CurrentRow.Index + 1
          End If
          If CurrentRowIndex &gt; ReferencesGrid.Rows.Count Then
              CurrentRowIndex = ReferencesGrid.Rows.Count - 1
          End If
  
          If ReferencesGrid.Rows.Count &gt; 0 Then
              For Each gRow As DataGridViewRow In ReferencesGrid.Rows
                  StringToSearch = gRow.Cells(1).Value.ToString.Trim.ToLower
                  If InStr(1, StringToSearch, LCase(Trim(SearchTextBox.Text)), vbTextCompare) Then
                      TrainingItemBindingSource.Filter = String.Format("Name LIKE '{0}'", ValueToSearchFor)
  
                      Exit For
                  End If
              Next
          End If
      Catch ex As Exception
          MsgBox(ex.ToString)
      End Try
  End Sub
  </code></pre>