本帖最后由 水木子 于 2009-11-14 17:25 编辑
理论的是读取、判断是否已经存在、添加三步。我没做过。
顽固不化 发表于 2009-11-14 10:48
顽固不化前辈说意思大概就是这样吧!#Include <Array.au3>
#Include <GuiComboBox.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ComboConstants.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Combo", 280, 180)
$Combo1 = GUICtrlCreateCombo("1", 50, 50, 120, 25)
GUICtrlSetData(-1, "2|3|4|5|6|7|8|9|10|", "1")
$Input1 = GUICtrlCreateInput("", 50, 100, 120, 21)
GUICtrlSetState ( -1, $GUI_FOCUS )
$Button1 = GUICtrlCreateButton("添加", 170, 98, 60, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Button1
Add()
EndSwitch
WEnd
Func Add()
$a = GUICtrlRead($Input1)
$all = _GUICtrlComboBox_GetListArray($Combo1)
If _ArraySearch($all,$a) = -1 Then
GUICtrlSetData($Combo1,$a)
MsgBox(0,"提示","新选 "&$a&" 项添加成功")
GUICtrlSetState ($Input1, $GUI_FOCUS )
Else
MsgBox(0,"提示","菜单中已经存在 "&$a&" 请勿重复添加!")
GUICtrlSetState ($Input1, $GUI_FOCUS )
EndIf
EndFunc
|