找回密码
 加入
搜索
查看: 3336|回复: 3

[AU3基础] 如何删除Combo选中的项目?[已解决]

[复制链接]
发表于 2012-9-28 18:26:02 | 显示全部楼层 |阅读模式
本帖最后由 sd23 于 2012-9-28 19:38 编辑

该搜的都搜了,该看的都仔细看了。。。。

请问各位前辈,这个方向正确吗?

$a1 = _GUICtrlComboBox_GetCurSel($Combo1)  
_GUICtrlListBox_DeleteString($Combo1, $a1)

目的:点击删除按钮就删除选中的项目

代码:
[au3]
#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
[au3]
发表于 2012-9-28 19:23:51 | 显示全部楼层
回复 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
 楼主| 发表于 2012-9-28 19:37:12 | 显示全部楼层
这么快解决了,非常非常感谢 shqf  !
发表于 2015-12-13 19:25:19 | 显示全部楼层
不知道有没有方法在鼠标放到项目上时在右边显示X,可以直接删除
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-29 00:19 , Processed in 0.090015 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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