以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]checkbox发布会后问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=137973)

--  作者:lxq3736
--  发布时间:2019/7/19 14:07:00
--  [求助]checkbox发布会后问题

checkbox1和checkbox2 为必须其一,互相排斥

代码放在都click中

chk1:

Dim chk1 As WinForm.CheckBox = e.Form.Controls("CheckBox1")

Dim chk2 As WinForm.CheckBox = e.Form.Controls("CheckBox2")

If chk1.checked=True Then

chk1.checked =True

chk2.checked =False

chk1.ForeColor=Color.LimeGreen

chk2.ForeColor=Color.black

Else

chk2.checked =True

chk1.checked =False

chk2.ForeColor=Color.LimeGreen

chk1.ForeColor=Color.black

End If

chk2:

Dim chk1 As WinForm.CheckBox = e.Form.Controls("CheckBox1")

Dim chk2 As WinForm.CheckBox = e.Form.Controls("CheckBox2")

If chk2.checked=True Then

chk2.ForeColor=Color.LimeGreen

chk1.ForeColor=Color.black

chk2.checked =True

chk1.checked =False

Else

chk1.checked =True

chk1.ForeColor=Color.LimeGreen

chk2.ForeColor=Color.black

chk2.checked =False

End If

开发时没有错误,发布后,点击几下竟然出现这种结果?


图片点击可在新窗口打开查看此主题相关图片如下:图片1.png
图片点击可在新窗口打开查看


--  作者:有点蓝
--  发布时间:2019/7/19 14:29:00
--  
放到checkchanged事件
chk1
Dim chk2 As WinForm.CheckBox = e.Form.Controls("CheckBox2")
if e.sender.checked then
chk2.checked = false

e.sender.ForeColor=Color.LimeGreen

chk2.ForeColor=Color.black

else

e.sender.ForeColor=Color.black

end if


建议使用单选框:http://www.foxtable.com/webhelp/topics/0782.htm