以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]复选框的问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=106782)

--  作者:zyl19810322
--  发布时间:2017/9/15 14:42:00
--  [求助]复选框的问题
在窗口中多个复选框控件,分成两组,如何设置两组内的复选框不能同时选择?
Dim a1 As WinForm.CheckBox = e.Form.Controls("CheckBox1")
Dim a2 As WinForm.CheckBox = e.Form.Controls("CheckBox2")
Dim a3 As WinForm.CheckBox = e.Form.Controls("CheckBox3")
Dim a4 As WinForm.CheckBox = e.Form.Controls("CheckBox4")
Dim a5 As WinForm.CheckBox = e.Form.Controls("CheckBox5")
Dim a6 As WinForm.CheckBox = e.Form.Controls("CheckBox6")
Dim a7 As WinForm.CheckBox = e.Form.Controls("CheckBox7")
Dim a8 As WinForm.CheckBox = e.Form.Controls("CheckBox8")
If a1.Checked = True Or a2.Checked = True Or a3.Checked = True Or a4.Checked = True Then
a5.Checked = False
a6.Checked = False
a7.Checked = False
a8.Checked = False
End If
If a5.Checked = True Or a6.Checked = True Or a7.Checked = True Or a8.Checked = True Then
a1.Checked = False
a2.Checked = False
a3.Checked = False
a4.Checked = False
End If
这样设置后5,6,7,8不能选择了,老师帮我看看阿有其他办法?谢谢老师

--  作者:有点甜
--  发布时间:2017/9/15 14:56:00
--  
 只有你这种方法,别无他法。如果你觉得你控件太多、想少写一些代码,你可以把代码写成循环的方式。但互斥必须写代码控制。