单击Button1时,使用CheckBox的My Filter DataGridView不起作用。请给我解决方案。我在下面附上我的代码:
Public Class Form1
Private Sub Table1BindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Table1BindingNavigatorSaveItem.Click
Me.Validate()
Me.Table1BindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.EmployeeTBDataSet)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'EmployeeTBDataSet.Table1' table. You can move, or remove it, as needed.
Me.Table1TableAdapter.Fill(Me.EmployeeTBDataSet.Table1)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim query As String = ""
Dim c1check As Boolean
Dim myList As New List(Of String)
For Each cb As CheckBox In GroupBox1.Controls.OfType(Of CheckBox)()
' we can know if checkbox in GroupBox1 is checked or not
If CheckBox1.Checked Then
c1check = True
' get the text of checkbox that checked by user
myList.Add(cb.Text)
End If
Next
If c1check Then
' if checkbox in groupbox1 is checked, we will create this query to our database
query = "SELECT ID FROM Table1 WHERE Status='" & String.Join("' or Status=" + "'", myList) + "'"
End If
End Sub
End Class