如何使用文本框搜索过滤datagridview
?我正在使用vb.net 2012并使用设计器连接到访问数据库和使用设计器的buld datagridview
*我的coulm我希望搜索名为“颜色”
Public Class Form1
Private Sub SalesBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles SalesBindingNavigatorSaveItem.Click
Me.Validate()
Me.SalesBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.ds)
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.SalesTableAdapter.Fill(Me.ds.sales)
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub SalesDataGridView_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles SalesDataGridView.CellContentClick
End Sub
End Class
答案 0 :(得分:0)
设计师也应该为您创建一个BindingSource。在文本框事件中,您可以将Filter应用于BindingSource.Filter属性。
bindingSource.Filter = "[Color] = '" & TextBox1.Text & "'"