Dear friends,
good Day.
I use DataGridView1 to display list of employees and I need to filter based on TextBox.Text.
But i tried in few but not get filter when TextBox.Text changes.
Could anyone please help me to get this done.
with Thanks
ebincharles
good Day.
I use DataGridView1 to display list of employees and I need to filter based on TextBox.Text.
But i tried in few but not get filter when TextBox.Text changes.
Code:
Imports System.Data.OleDb
Imports System.IO
Public Class Form1
'Global Declaration for Class frmSM
Dim AddMode As Boolean
Dim Ctrl As Integer
Dim myConn As New OleDbConnection
Dim myCmd As New OleDbCommand
Dim myDA As New OleDbDataAdapter
Dim myDR As OleDbDataReader
Dim strSQL As String
Private Property DBPath As String
Function IsConnected() As Boolean
Try
'Checks first if already connected to database,if connected, it will be disconnected.
If myConn.State = ConnectionState.Open Then myConn.Close()
myConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\dbLab.mdb;"
myConn.Open()
IsConnected = True
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function
Private Sub txtSearchBox_TextChanged(ByVal Sender As System.Object, ByVal e As System.EventArgs) Handles txtSearchBox.TextChanged
myDA = New OleDbDataAdapter("Select * From tblStudentMaster", myConn)
Dim DtSet As New DataSet
myDA.Fill(DtSet)
Dim bs As New BindingSource
bs.DataSource = DtSet
bs.Filter = " SM_ID LIKE'" & txtSearchBox.Text & "*' Or SM_FName LIKE '" & txtSearchBox.Text & "*' Or SM_LName LIKE '" & txtSearchBox.Text & "*' Or SM_MName LIKE '" & txtSearchBox.Text & "*'"
DataGridView1.DataSource = DtSet.Tables(0)
myConn.Close()
'' Dim row As DataGridViewRow = DataGridView1.Rows(0)
'' row.Height = 20
End Sub
with Thanks
ebincharles