找回密码
 加入
搜索
查看: 2034|回复: 14

GUICtrlCreateCombo输人的数据,能否用GUICtrlSetData加到列表框中?

 火.. [复制链接]
发表于 2009-11-13 19:48:02 | 显示全部楼层 |阅读模式
本帖最后由 Nonenever 于 2009-11-21 22:50 编辑

GUICtrlCreateCombo输人的数据,能否用GUICtrlSetData加到列表框中?

只是在GUICtrlCreateCombo中添加数据
如何才能办到?

把item4加进去

黙认情况下,去选其它的话,item4就没有了
如何才能使item4仍然有



见11楼

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2009-11-14 10:48:19 | 显示全部楼层
本帖最后由 顽固不化 于 2009-11-14 10:49 编辑

理论的是读取、判断是否已经存在、添加三步。我没做过。
发表于 2009-11-14 12:59:01 | 显示全部楼层
论坛上我记得好像有你这个源代码的你去找咋
发表于 2009-11-14 17:19:16 | 显示全部楼层
本帖最后由 水木子 于 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        
 楼主| 发表于 2009-11-14 19:20:22 | 显示全部楼层
本帖最后由 Nonenever 于 2009-11-14 19:21 编辑

通过button添加这个可以
我的意思是只用GUICtrlCreateCombo输人的数据,没有button按钮
 楼主| 发表于 2009-11-14 19:31:38 | 显示全部楼层
好像需要一直监誢GUICtrlCreateCombo,GUICtrlRead,比较,改变了就把它添加进去
发表于 2009-11-14 21:08:13 | 显示全部楼层
好像需要一直监誢GUICtrlCreateCombo,GUICtrlRead,比较,改变了就把它添加进去
Nonenever 发表于 2009-11-14 19:31

如何是这样的话,岂不是很容易出错吗?
发表于 2009-11-15 03:07:10 | 显示全部楼层
本帖最后由 netegg 于 2009-11-15 03:08 编辑

那个combo是可接受输入的?还是定值?如果是可输入的,直接获取输入焦点,然后设置回你要设置的地方,或者控件里,应该可以把,如果要是读取的话,应该更方便
还有,udf好像有获取combo变化这个函数
 楼主| 发表于 2009-11-17 13:50:29 | 显示全部楼层
回复 8# netegg


    查看一下
发表于 2009-11-17 13:59:48 | 显示全部楼层
回复 9# Nonenever

查什么?
发表于 2009-11-17 14:48:29 | 显示全部楼层
按回车键添加~
#include <GuiComboBox.au3>

HotKeySet("{Enter}", "Enter")
$Form1 = GUICreate("combo test", 300, 200)
$combo = GUICtrlCreateCombo("", 20, 20, 150)
GUICtrlSetData(-1, "item1|item2|item3", "item3")
GUISetState()

While 1
        $msg = GUIGetMsg()
        If $msg = -3 Then ExitLoop
WEnd

Func Enter()
        If WinActive($Form1) Then
                $Rc = GUICtrlRead($combo)
                If _GUICtrlComboBox_FindStringExact($combo, $Rc) = -1 Then _GUICtrlComboBox_AddString($combo, $Rc)
        Else
                HotKeySet("{enter}")
                Send("{enter}")
                HotKeySet("{enter}", "enter")
        EndIf
EndFunc   ;==>Enter
发表于 2009-11-17 14:58:19 | 显示全部楼层
#Include <GuiComboBox.au3>
_GUICtrlComboBox_InsertString($hWnd, $sText[, $iIndex = -1])
发表于 2009-12-2 17:57:24 | 显示全部楼层
楼上的这个很强大 是自带的用户自定义函数中的,超级好用
发表于 2009-12-2 22:53:19 | 显示全部楼层
这个功能偶常用,学习了
发表于 2009-12-2 23:05:15 | 显示全部楼层
LZ解决了问题至少应该回个帖,不然别人不知道你到底解决没。
不要一声不吭,悄悄的在一楼最底下编辑个“见11楼”。11楼是答案?还是问题?
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-9 02:46 , Processed in 0.083732 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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