如何在程序中添加过滤功能,这样当我开始在文本框中输入时,它会在DataGridView中过滤结果?为了澄清,此代码在表单加载时将链接的Access数据库加载到DataGridView中,并允许我添加,删除和更新包含在其中的数据。
我对Visual Basic比较陌生,但为了让它工作起来,我已经用尽了什么。提前感谢您提供的任何帮助!
Imports System.Data.OleDb
Public Class frmDatabase
Dim con As New OleDbConnection
Dim ds As New DataSet
Dim dt As New DataTable
Dim da As New OleDbDataAdapter
Private Sub frmDatabase_Load(sender As Object, e As EventArgs) Handles MyBase.Load
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Joe\Documents\Visual Studio 2012\Projects\school database viewer\school database viewer\dbSchoolDatabase.mdb"
con.Open()
ds.Tables.Add(dt)
da = New OleDbDataAdapter("Select * from tableStudentDetails", con)
Dim cb = New OleDbCommandBuilder(da)
cb.QuotePrefix = "["
cb.QuoteSuffix = "]"
da.Fill(dt)
dgvStudentDetails.DataSource = dt.DefaultView
con.Close()
End Sub
Private Sub cmdSave_Click_1(sender As Object, e As EventArgs) Handles cmdSave.Click
da.Update(dt)
End Sub