如何删除Combo选中的项目?[已解决]
本帖最后由 sd23 于 2012-9-28 19:38 编辑该搜的都搜了,该看的都仔细看了。。。。
请问各位前辈,这个方向正确吗?
$a1 = _GUICtrlComboBox_GetCurSel($Combo1)
_GUICtrlListBox_DeleteString($Combo1, $a1)
目的:点击删除按钮就删除选中的项目
代码:
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiListBox.au3>
#include <GuiComboBox.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 430, 209, 192, 124)
$Combo1 = GUICtrlCreateCombo("Combo1", 80, 72, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "aa|bb|cc|dd|ee|ff")
GUICtrlSetOnEvent(-1, "Combo1Change")
$Button1 = GUICtrlCreateButton("删除", 264, 72, 75, 25)
GUICtrlSetOnEvent(-1, "Button1Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func Button1Click()
$a1 = _GUICtrlComboBox_GetCurSel($Combo1)
_GUICtrlListBox_DeleteString($Combo1, $a1)
EndFunc
Func Combo1Change()
EndFunc
回复 1# sd23
_GUICtrlListBox_DeleteString()是操作下拉列表框的,而不是组合列表框,应用
_GUICtrlComboBox_DeleteString()#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListBox.au3>
#include <GuiComboBox.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 430, 209, 192, 124)
$Combo1 = GUICtrlCreateCombo("Combo1", 80, 72, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "aa|bb|cc|dd|ee|ff")
$Button1 = GUICtrlCreateButton("删除", 264, 72, 75, 25)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$a1 = _GUICtrlComboBox_GetCurSel($Combo1)
_GUICtrlComboBox_DeleteString($Combo1, $a1)
_GUICtrlComboBox_SetCurSel($Combo1, 0)
EndSwitch
WEnd
这么快解决了,非常非常感谢 shqf! 不知道有没有方法在鼠标放到项目上时在右边显示X,可以直接删除
页:
[1]