如何批量添加复选框且分行排列[已解决]
本帖最后由 872777825 于 2013-3-10 22:13 编辑如上图
小弟想这样体检一批复选框有没有好的办法可以批量添加
而不需要一个个定位添加呢$B1box = GUICtrlCreateCheckbox("", 288, 188, 13, 13)
$B1box = GUICtrlCreateCheckbox("", 437, 188, 13, 13)
$B1box = GUICtrlCreateCheckbox("", 586, 188, 13, 13)
$B1box = GUICtrlCreateCheckbox("", 735, 188, 13, 13)
$B1box = GUICtrlCreateCheckbox("", 288, 277, 13, 13)
$B1box = GUICtrlCreateCheckbox("", 437, 277, 13, 13)
$B1box = GUICtrlCreateCheckbox("", 586, 277, 13, 13)
$B1box = GUICtrlCreateCheckbox("", 735, 277, 13, 13)
$B1box = GUICtrlCreateCheckbox("", 288, 366, 13, 13)
$B1box = GUICtrlCreateCheckbox("", 437, 366, 13, 13)
$B1box = GUICtrlCreateCheckbox("", 586, 366, 13, 13)
$B1box = GUICtrlCreateCheckbox("", 735, 366, 13, 13)
$B1box = GUICtrlCreateCheckbox("", 288, 455, 13, 13)
$B1box = GUICtrlCreateCheckbox("", 437, 455, 13, 13)
$B1box = GUICtrlCreateCheckbox("", 586, 455, 13, 13)
$B1box = GUICtrlCreateCheckbox("", 735, 455, 13, 13)如上面这样就感觉有点不太人性化了
望各位老大抽点时间指点下
先谢为敬~! 弄个内嵌的IE,用网页的形式实现 回复 2# kevinch
这样工程会不会更大 ? 本帖最后由 afan 于 2013-3-10 22:14 编辑
Local $aiCkbox, $iLs = 4, $iSpacingX = 140, $iSpacingY = 80, $_Xbj = 140, $_Ybj = 70
GUICreate('', 600, 350)
For $i = 0 To UBound($aiCkbox) - 1
$aiCkbox[$i] = GUICtrlCreateCheckbox('', $iSpacingX * Mod($i, $iLs) + $_Xbj, $iSpacingY * Floor($i / $iLs) + $_Ybj, 20, 20)
Next
GUISetState()
While GUIGetMsg() <> -3
WEnd
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("MustDeclareVars", 1)
Const $x0 = 15
Const $y0 = 10
Const $x_dis = 50
Const $y_dis = 50
Global $nMsg
Global $chkbox
Local $i
Local $j
#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("Form1", 623, 449, 192, 114)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
For $i = 0 To UBound($chkbox, 1)-1
For $j = 0 To UBound($chkbox, 2)-1
$chkbox[$i][$j] = GUICtrlCreateCheckbox("", $x0+$j*$y_dis, $y0+$i*$x_dis, 13, 13)
Next
Next
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
回复 4# afan
谢谢版主可以亲自回复 回复 5# veket_linux
谢谢veket_linux姐姐 回复 6# 872777825
之前的多了一行… 回复 8# afan
嗯看到了那个修改一下简单
不过现在又不知道怎么做全选以及全不选了 -_- 回复 9# 872777825 Local $aiCkbox, $iLs = 4, $iSpacingX = 140, $iSpacingY = 80, $_Xbj = 140, $_Ybj = 70
GUICreate('测试', 600, 350)
$iBt0 = GUICtrlCreateButton('全选', 150, 20, 80, 22)
$iBt1 = GUICtrlCreateButton('反选', 240, 20, 80, 22)
$iBt2 = GUICtrlCreateButton('全否', 330, 20, 80, 22)
For $i = 0 To UBound($aiCkbox) - 1
$aiCkbox[$i] = GUICtrlCreateCheckbox('', $iSpacingX * Mod($i, $iLs) + $_Xbj, $iSpacingY * Floor($i / $iLs) + $_Ybj, 20, 20)
Next
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
Case -3
Exit
Case $iBt0, $iBt2
For $i = 0 To UBound($aiCkbox) - 1
GuiCtrlSetState($aiCkbox[$i], ($msg - $iBt0 <> 0) * 3 + 1)
Next
Case $iBt1
For $i = 0 To UBound($aiCkbox) - 1
GuiCtrlSetState($aiCkbox[$i], (GuiCtrlRead($aiCkbox[$i]) = 1) * 3 + 1)
Next
EndSwitch
WEnd 回复 10# afan
再次感谢afan版主老大 呵呵。。。A版再现,问题不见 回复 12# xyhqqaa
“A版再现,问题不见”,呵呵,这话经典啊!{:face (411):}
页:
[1]