让2个下拉菜单联动[已解决]
本帖最后由 ainizm 于 2012-2-25 19:42 编辑请教,如何让2个下拉菜单联动
比如:菜单1内容是1、2、3 ,菜单2内容是A、B、C,如何选中菜单1时,菜单同时选中A,或选中B时,菜单同时选中2 回复 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
#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
#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
If GUICtrlRead($hwd) = $1[$i] Then _
GUICtrlSetData($hwd2, $2[$i])
Next
EndFunc ;==>aaa 非常感谢,尤其感谢lixiaolong
页:
[1]