【发布时间】:2015-09-29 21:56:07
【问题描述】:
好的,所以我想要做的是在选中一个复选框时,在这种情况下将选中“添加”> 在选中时,我将如何制作一个弹出窗口,说“你不能一次选择两个以上的值" 或其他东西,这样他们就无法选中两个框并使程序崩溃。这是我的代码:
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
Dim Addition As String
Dim Subtraction As String
Dim Multiplication As String
Multiplication = CheckBox3.CheckState
Subtraction = CheckBox2.CheckState
Addition = CheckBox1.CheckState
If Addition = CheckState.Checked Then
'label icon of the current calculation sign
neum.Text = "+"
'label icon of the current calculation sign
Me.CheckBox2.CheckState = CheckState.Unchecked
Me.CheckBox3.CheckState = CheckState.Unchecked
End If
If Addition = CheckState.Unchecked Then
neum.Text = " "
End If
End Sub
【问题讨论】:
-
听起来你想要set of radio buttons,而不是复选框。
-
所以用复选框我不能说“你不能同时选中两个框”之类的东西?
-
你可以,但这正是单选按钮的设计目的,也是用户的期望。
-
我明白了,我会给他们一个机会。你有任何我应该与单选按钮一起使用的代码吗?
-
并非如此 - 只要您将它们正确组合在一起(我的第一条评论中的链接中的详细信息),它们将自动停止一次选择多个而不需要任何代码