如何点一下按钮,然后让CheckBox为选中状态?
我的意思是:我点一下“全选”按钮,然后所有的CheckBox全部处于选中状态,当然,单个点击CheckBox后要执行其下的代码,如表示按下的变量$Down=1,如何实现,本人初学,找不到资料,希望给予解答,谢谢! 本帖最后由 netegg 于 2011-4-21 22:36 编辑guictrlsetonevent($check, 'doit' )
func doit()
if bitor(guictrlread($check), $gui_uncecked) then
guictrlsetstate($check, $gui_checked)
msgbox(0,0,0)
else
guictrlsetstate($check, $gui_unchecked)
endif
endfunc 学习中。。。。。。 蛋蛋的方法就OK了!用循环也行! 我试试,先谢谢提供帮助 ...找不到资料,按f1 不知道这样行得通不?
guictrlsetonevent($check, 'doit' )
Global $state=,$val=0
func doit()
guictrlsetstate($check, $state[$val])
$val=Not $val
endfunc 一个例子
#include <GUIConstantsEx.au3>
GUICreate(" GUI 复选框") ; 创建居中显示的对话框窗口
$checkCN1 = GUICtrlCreateCheckbox("复选框 1", 10, 10)
$checkCN2 = GUICtrlCreateCheckbox("复选框 2", 10, 30)
$checkCN3 = GUICtrlCreateCheckbox("复选框 3", 10, 50)
$checkCN4 = GUICtrlCreateCheckbox("复选框 4", 10, 70)
$checkCN5 = GUICtrlCreateCheckbox("复选框 5", 10, 90)
$checkCN6 = GUICtrlCreateCheckbox("复选框 6", 10, 110)
$checkCN7 = GUICtrlCreateCheckbox("复选框 7", 10, 130)
$checkCN8 = GUICtrlCreateCheckbox("复选框 8", 10, 150)
$checkCN9 = GUICtrlCreateCheckbox("复选框 9", 10, 170)
$checkCN10 = GUICtrlCreateCheckbox("复选框 10", 10, 190)
$btn = GUICtrlCreateButton("全选", 10, 220)
$btn2 = GUICtrlCreateButton("全不选", 10, 250)
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $checkCN1
Check($checkCN1)
Case $msg = $checkCN2
Check($checkCN2)
Case $msg = $checkCN3
Check($checkCN3)
Case $msg = $btn
Checkbox()
Case $msg = $btn2
UnCheckbox()
Case $msg = $GUI_EVENT_CLOSE
Exit
EndSelect
WEnd
Func Check($check)
If GUICtrlRead($check) = $GUI_CHECKED Then _
MsgBox(0, "", "您选择了" & GUICtrlRead($check, 1))
EndFunc ;==>Check
Func Checkbox()
For $i = 1 + 2 To 10 + 2
$s = Eval("checkCN") & Eval("i")
GUICtrlSetState($s, $GUI_CHECKED)
Next
EndFunc ;==>Checkbox
Func UnCheckbox()
For $i = 1 + 2 To 10 + 2
$s = Eval("checkCN") & Eval("i")
GUICtrlSetState($s, $GUI_UNCHECKED)
Next
EndFunc ;==>UnCheckbox 本帖最后由 netegg 于 2011-4-23 20:59 编辑
回复 7# 3mile
逻辑上应该没问题
页:
[1]