您的位置:程序门 -> vb -> 基础类



为什么复选框要点两次?如何解决?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


为什么复选框要点两次?如何解决?[已结贴,结贴人:xinjw]
发表于:2008-01-21 16:54:16 楼主
private   sub   chkctrl_click()

        if   len(txtadd.text)   <=   0   then
                msgbox   "请先确定商品规格才能继续操作!",   vbokonly   +   vbexclamation,   "提示"
                txtadd.setfocus
                chkctrl.value   =   false
                exit   sub
        end   if

end   sub

我想要的结果是:如果txtadd为空的话,那么点击chkctrl话,不能继续操作,txtadd获得焦点,并且chkctrl的值为false.用上面的程序能实现,但是总是出现两次msgbox.
发表于:2008-01-21 17:01:481楼 得分:10
在设置checkbox的值时,会触发它的click事件
发表于:2008-01-21 17:05:112楼 得分:0
对啊.如何让他不让它触发click事件,而是悄无声息的去做.
发表于:2008-01-21 17:36:403楼 得分:0
用mousedown事件
private   sub   chkctrl_mousedown(button   as   integer,   shift   as   integer,   x   as   single,   y   as   single)
        if   len(txtadd.text)   <=   0   then
                msgbox   "请先确定商品规格才能继续操作!",   vbokonly   +   vbexclamation,   "提示"
                txtadd.setfocus
                chkctrl.value   =   false
        end   if
end   sub
发表于:2008-01-21 17:38:124楼 得分:0
感觉你的逻辑很奇怪
发表于:2008-01-21 17:44:135楼 得分:0
3楼,你的做法看样子应该是正确的,但是如果触发keypress事件的话,那还是没达到我的效果啊.txtadd为空,但是chkctrl的值确为true
发表于:2008-01-22 08:22:086楼 得分:0
private   sub   chkctrl_mousedown(button   as   integer,   shift   as   integer,   x   as   single,   y   as   single)
        if   len(txtadd.text)   <=   0   then
                msgbox   "请先确定商品规格才能继续操作!",   vbokonly   +   vbexclamation,   "提示"
                txtadd.setfocus
                chkctrl.value   =   false
        end   if
end   sub

private   sub   txtadd_keydown(keycode   as   integer,   shift   as   integer)
        if   len(txtadd)   >   0   then   chkctrl   =   false
end   sub


快速检索

最新资讯
热门点击