[Solved] Datagridview Filter only works when exact text is typed
Ok so my import code is
Code:
Dim dt As New DataTable
Using cn As New OleDb.OleDbConnection With {.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\ExcelWork.xlsx;Extended Properties=""Excel 12.0 Xml;HDR=YES"""}
Using cmd As New OleDb.OleDbCommand With {.Connection = cn}
cmd.CommandText = "SELECT * FROM [Sheet1$]"
cn.Open()
dt.Load(cmd.ExecuteReader)
End Using
End Using
bsData.DataSource = dt
DataGridView1.DataSource = bsData
I have the WithEvents thing at the top
Code:
Public Class Form1
WithEvents bsData As New BindingSource
My filtering statement is (It's in a textchanged Sub)
Code:
bsData.Filter = "PartNumber = '" & txtSearch.Text & "'"
To filter the PartNumber Column for the text in txtSearch
When I filter the filter only works if I type the EXACT text (which is a long part number) in the text box. Shouldn't it just reduce the results so I don't have to type the whole thing
Re: Datagridview Filter only works when exact text is typed
As you were posting this, I answered the question in the other thread.
Re: Datagridview Filter only works when exact text is typed
Yay this works
bsData.Filter = String.Format("PartNumber Like '%{0}%'", txtSearch.Text)