找回密码
 加入
搜索
查看: 1552|回复: 4

[AU3基础] 让2个下拉菜单联动[已解决]

[复制链接]
发表于 2012-2-25 16:16:24 | 显示全部楼层 |阅读模式
本帖最后由 ainizm 于 2012-2-25 19:42 编辑

请教,如何让2个下拉菜单联动
比如:菜单1内容是1、2、3 ,菜单2内容是A、B、C,如何选中菜单1时,菜单同时选中A,或选中B时,菜单同时选中2
发表于 2012-2-25 16:45:51 | 显示全部楼层
回复 1# ainizm
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 399, 233, 350, 396)
$Combo1 = GUICtrlCreateCombo("1", 22, 24, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "2|3")
$Combo2 = GUICtrlCreateCombo("A", 198, 26, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "B|C")
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Combo1
                        $gt = GUICtrlRead($Combo1)
                        If $gt = "1" Then
                                GUICtrlSetData($Combo2, "A", 1)
                        ElseIf $gt = "2" Then
                                GUICtrlSetData($Combo2, "B", 1)
                        ElseIf $gt = "3" Then
                                GUICtrlSetData($Combo2, "C", 1)
                        EndIf
        EndSwitch
WEnd
发表于 2012-2-25 18:14:11 | 显示全部楼层

#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>

#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 168, 104, 193, 125)
$Combo1 = GUICtrlCreateCombo("", 16, 8, 137, 25)
GUICtrlSetData(-1, "请选择...|A|B|C", "请选择...")
$Combo2 = GUICtrlCreateCombo("", 16, 39, 137, 25)
$Input = GUICtrlCreateInput("", 16, 70, 137, 25, $ES_readonly)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Combo1
                        Switch GUICtrlRead($Combo1)
                                Case "A"
                                        GUICtrlSetData($Combo2, "")
                                        GUICtrlSetData($Combo2, "A1|A2|A3|A4|A5|A6|A7|A8|A9|", "A1")
                                Case "B"
                                        GUICtrlSetData($Combo2, "")
                                        GUICtrlSetData($Combo2, "B1|B2|B3|B4|B5|B6|B7|B8|B9| ", "B1")
                                Case "C"
                                        GUICtrlSetData($Combo2, "")
                                        GUICtrlSetData($Combo2, "C1|C2|C3|C4|C5|C6|C7|C8|C9| ", "C1")
                                Case Else
                                        GUICtrlSetData($Combo2, "")
                        EndSwitch
                Case $Combo2
                        $T = GUICtrlRead($Combo2)
                        GUICtrlSetData($Input, $T)
        EndSwitch
WEnd

评分

参与人数 1金钱 +10 收起 理由
lixiaolong + 10 学习了!

查看全部评分

发表于 2012-2-25 18:45:58 | 显示全部楼层
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiComboBox.au3>


#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 399, 233, 350, 396)
$Combo1 = GUICtrlCreateCombo("1", 22, 24, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "2|3")
$Combo2 = GUICtrlCreateCombo("A", 198, 26, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "B|C")
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
$gt = _GUICtrlComboBox_GetListArray($Combo1)
$gs = _GUICtrlComboBox_GetListArray($Combo2)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Combo1
                        aaa($Combo1, $Combo2, $gt, $gs)
                Case $Combo2
                        aaa($Combo2, $Combo1, $gs, $gt)
        EndSwitch
WEnd

Func aaa($hwd, $hwd2, ByRef $1, ByRef $2)
        For $i = 1 To $1[0]
                If GUICtrlRead($hwd) = $1[$i] Then _
                                GUICtrlSetData($hwd2, $2[$i])
        Next
EndFunc   ;==>aaa
 楼主| 发表于 2012-2-25 19:14:04 | 显示全部楼层
非常感谢,尤其感谢lixiaolong
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-11-19 13:41 , Processed in 0.096822 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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