如何在vb.net中执行搜索后刷新Datagrid

时间:2016-05-10 11:40:28

标签: vb.net

我需要一个按钮代码来刷新数据网格,以便在我在vb2010应用程序中执行搜索后显示完整列表。例如,如果我的列表有100个客户,我搜索奥巴马并得到5个结果,我将如何回到我的100个客户完整列表?

Tbx2.Text = DataGridView1.RowCount()

If Cbx1.Text = "Adm. No." Then
    Me.StudentsBindingSource.Filter = "AdmissionNumber = '" & Tbx1.Text & "'"
ElseIf Cbx1.Text = "Name" Then
    Me.StudentsBindingSource.Filter = "FullName Like '%" & Tbx1.Text & "%'"
ElseIf Cbx1.Text = "Class/Stream" Then
    Me.StudentsBindingSource.Filter = "Class_Stream Like '%" & Tbx1.Text & "%'"
ElseIf Cbx1.Text = "County" Then
    Me.StudentsBindingSource.Filter = "County = '" & Tbx1.Text & "'"
End If` This is my search code and its working fine

1 个答案:

答案 0 :(得分:0)

使用Me.StudentsBindingSource.RemoveFilter()将过滤器设置为空,并显示所有行。