我试图在双击组合框时选择所有复选框,因为它很简单,但是现在我想在再次双击组合框时取消选中所有复选框,这里是' s我有什么:
Private Sub GroupBox1_DoubleClick(sender As System.Object, _
e As System.EventArgs) Handles GroupBox1.DoubleClick
CheckBox1.Checked = True : CheckBox2.Checked = True
CheckBox3.Checked = True : CheckBox4.Checked = True
CheckBox5.Checked = True : CheckBox6.Checked = True
End Sub
(是的,我不使用选中的列表框)
那么,我该如何实现呢?
答案 0 :(得分:1)
Checked属性是一个布尔值,因此您可以应用布尔值Not operator来反转Checked属性的当前值
Private Sub GroupBox1_DoubleClick(sender As System.Object, e As System.EventArgs) Handles GroupBox1.DoubleClick
CheckBox1.Checked = Not CheckBox1.Checked
CheckBox2.Checked = Not CheckBox2.Checked
CheckBox3.Checked = Not CheckBox3.Checked
CheckBox4.Checked = Not CheckBox4.Checked
CheckBox5.Checked = Not CheckBox5.Checked
CheckBox6.Checked = Not CheckBox6.Checked
End Sub