找回密码
 加入
搜索
查看: 3278|回复: 14

[AU3基础] 複選按鈕的選擇??[已解決]

 火.. [复制链接]
发表于 2012-1-15 13:46:29 | 显示全部楼层 |阅读模式
本帖最后由 jericho0711 于 2012-1-15 22:48 编辑

AU3里面目前都是單選跟複選,如果有20個checkbox選擇在同一個頁面,左右各10個,有辦法限制左右只能勾選一個框框,不知有沒有這種方式..
发表于 2012-1-15 13:57:11 | 显示全部楼层
最好是 两两单选,避免多余的代码,
全部复选的话要写判断,繁琐一些
发表于 2012-1-15 13:59:39 | 显示全部楼层
本帖最后由 netegg 于 2012-1-15 14:00 编辑

说明白什么情况,别这么提问,问的不清不楚,怎么回答
表达不在行,就上图
发表于 2012-1-15 14:04:23 | 显示全部楼层
他的意思好像是10个复选框只能有一个勾选的吧
发表于 2012-1-15 14:14:56 | 显示全部楼层
他的意思是
复选1  复选2
复选3  复选4
复选5 复选6
复选7 复选8
复选9 复选10
左右相邻的之能选一个,也就是说,10个框最多选5个
我是建议左右两个做成单选,是一组,共5组
发表于 2012-1-15 14:17:42 | 显示全部楼层
晕,左右只能勾选一个干嘛不用单选的呢
发表于 2012-1-15 14:22:23 | 显示全部楼层
应该就是 love5173 的意思,楼主也不出来吱一声
用两组单选就了,一个页面的要求 GUIStartGroup()
 楼主| 发表于 2012-1-15 15:54:24 | 显示全部楼层
新手剛開始學GUI,左右各一排,左邊1、5、9只能點選1個,右邊2、6、10只能點選一個,點選完後按下start會執行各自對應的代碼。
圖片所示,點選框-5後,框1、9會變disable;點選框-6的話,框2、10會變disable

发表于 2012-1-15 16:19:57 | 显示全部楼层
用分组+单选框
发表于 2012-1-15 16:22:28 | 显示全部楼层
...
點選框-5後,框1、9會變disable;點選框-6的話,框2、10會變disable
...
jericho0711 发表于 2012-1-15 15:54



    disable 后你想改变怎么办?如此不合理的想法… 为何不用单选框?这么多人的意见你都不听
 楼主| 发表于 2012-1-15 16:25:57 | 显示全部楼层
disable 后你想改变怎么办?如此不合理的想法… 为何不用单选框?这么多人的意见你都不听
afan 发表于 2012-1-15 16:22



單選框是使用radio嗎,可以麻煩教學一下分組+單選框的方式嗎?
发表于 2012-1-15 17:03:30 | 显示全部楼层
[au3]#include <GUIConstantsEx.au3>

Example()

Func Example()
        Local $msg
        GUICreate("My GUI radio") ; will create a dialog box that when displ1--ayed is centered
        Local $aRadio[6]
        GUICtrlCreateGroup('', 50, 50, 100, 150)
        For $i = 0 To 2
                $aRadio[$i] = GUICtrlCreateRadio($i, 50, $i * 50 + 50, 100, 20)
        Next
        GUICtrlCreateGroup("", -99, -99, 1, 1)
        GUICtrlCreateGroup('', 50, 150, 100, 150)
        For $i = 3 To 5
                $aRadio[$i] = GUICtrlCreateRadio($i, 200, $i * 50 + 50, 100, 20)
        Next
        GUICtrlCreateGroup("", -99, -99, 1, 1)

        GUISetState() ; will display an  dialog box with 1 checkbox

        ; Run the GUI until the dialog is closed
        While 1
                $msg = GUIGetMsg()
                Select
                        Case $msg = $GUI_EVENT_CLOSE
                                ExitLoop
                                #cs
                                        Case $msg = $radio1 And BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED
                                        MsgBox(64, 'Info:', 'You clicked the Radio 1 and it is Checked.')
                                        Case $msg = $radio2 And BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED
                                        MsgBox(64, 'Info:', 'You clicked on Radio 2 and it is Checked.')
                                #ce
                EndSelect
        WEnd
EndFunc   ;==>Example
[/au3]
写的比较乱,lz自己想想吧
发表于 2012-1-15 17:18:21 | 显示全部楼层
写了个简单又完整点的
#Include <GuiButton.au3>

GUICreate('分组单选框例子 by afan')

Local $Radio[6], $L = 1, $R = 5
$Radio[0] = GUICtrlCreateRadio('dgsdgfgsdg', 30, 30 * 1 - 15)
$Radio[1] = GUICtrlCreateRadio('gjgsfsfg', 30, 30 * 2 - 15)
$Radio[2] = GUICtrlCreateRadio('lkhjlhjljhlffgfw', 30, 30 * 3 - 15)

GUIStartGroup()
$Radio[3] = GUICtrlCreateRadio('gfjt86rgn', 200, 30 * 1 - 15)
$Radio[4] = GUICtrlCreateRadio('ulku6856784h', 200, 30 * 2 - 15)
$Radio[5] = GUICtrlCreateRadio('nghjgk', 200, 30 * 3 - 15)

GuiCtrlSetState($Radio[$L], 1)
GuiCtrlSetState($Radio[$R], 1)

$Button = GUICtrlCreateButton('读取或执行', 100, 300, 150, 20)

GUISetState()

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case -3
                        Exit
                Case $Radio[0] To $Radio[2]
                        $L = $nMsg - 3
                Case $Radio[3] To $Radio[5]
                        $R = $nMsg - 3
                Case $Button
                        MsgBox(0, '选中了', _GUICtrlButton_GetText($Radio[$L]) & @LF & _
                                        _GUICtrlButton_GetText($Radio[$R]))
                        _Go($L)
                        _Go($R)
        EndSwitch
WEnd

Func _Go($iX)
        Switch $iX
                Case 0
                        MsgBox(0, '', '执行左1任务')
                Case 1
                        MsgBox(0, '', '执行左2任务')
                Case 2
                        MsgBox(0, '', '执行左3任务')
                Case 3
                        MsgBox(0, '', '执行右1任务')
                Case 4
                        MsgBox(0, '', '执行右2任务')
                Case 5
                        MsgBox(0, '', '执行右3任务')
        EndSwitch
EndFunc
 楼主| 发表于 2012-1-15 22:42:21 | 显示全部楼层
写了个简单又完整点的
afan 发表于 2012-1-15 17:18


感謝了,真的很完整,試了一下很符合,需要花點時間研究一下,才剛剛開始GUI的練習....
发表于 2012-1-16 15:01:34 | 显示全部楼层
回复 13# afan

以前还没做过分组的学习了!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-30 23:36 , Processed in 0.094872 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表