is it possible to use the event for all checkboxes? I have two Checkboxes, when I activate one the other is deactivated. It goes in a loop. when I try to deactivate a checkbox, the CheckedChanged of disactivaed checkbox is called and generate a loop error
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
Dim da As MySqlDataAdapter
Dim dt As DataTable
If CheckBox1.Checked = True Then
CheckBox2.CheckState = CheckState.Unchecked
Openconnection()
da = New MySqlDataAdapter("SELECT * FROM User WHERE " & Cbx_Filter.Text & " LIKE'" & Txt_Filter.Text & "%' and Stats = 'OK'", Connections)
Else
If CheckBox2.Checked = False Then
Openconnection()
da = New MySqlDataAdapter("SELECT * FROM User WHERE " & Cbx_Filter.Text & " LIKE'" & Txt_Filter.Text & "%'", Connections)
End If
End If
dt = New DataTable
da.Fill(dt)
DataGridView1.Columns.Clear()
DataGridView1.DataSource = dt
Connections.Close()
da.Dispose()
and checkbox2
Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox2.CheckedChanged
Dim da As MySqlDataAdapter
Dim dt As DataTable
If CheckBox2.Checked = True Then
CheckBox1.CheckState = CheckState.Unchecked
Openconnection()
da = New MySqlDataAdapter("SELECT * FROM User WHERE " & Cbx_Filter.Text & " LIKE'" & Txt_Filter.Text & "%' and Stats = ''", Connections)
Else
If CheckBox1.Checked = False Then
Openconnection()
da = New MySqlDataAdapter("SELECT * FROM User WHERE " & Cbx_Filter.Text & " LIKE'" & Txt_Filter.Text & "%'", Connections)
End If
End If
dt = New DataTable
da.Fill(dt)
DataGridView1.Columns.Clear()
DataGridView1.DataSource = dt
Connections.Close()
da.Dispose()
End Sub
Aucun commentaire:
Enregistrer un commentaire