找回密码
 加入
搜索
查看: 2004|回复: 10

[AU3基础] GUICtrlSetData如何默认选中第一项[已解决]

  [复制链接]
发表于 2016-11-28 10:28:03 | 显示全部楼层 |阅读模式
本帖最后由 heroxianf 于 2016-11-28 16:46 编辑

GUICtrlSetData(-1, "条目 1|条目 2|条目 3", "条目 3")

在某些时候批量添加下拉菜单,我也不知道有什么字符,我想添加数据后,默认选中第一个菜单如何实现呢、。?

GUICtrlSetData(-1, "条目 1|条目 2|条目 3", "1")   这里可以这样设置参数就好了,1就选中第一个。

答案在8楼
发表于 2016-11-28 11:18:54 | 显示全部楼层
LZ试下是否可行
GUICtrlSetData($Combo1, "条目 1|条目 2|条目 3",“条目 1”)
 楼主| 发表于 2016-11-28 11:37:54 | 显示全部楼层
回复 2# dnvplj

我希望是模糊选择的,只是知道目录里有下拉菜单项的数目,想通过制定第几个来选择。其实下面代码就可以实现了,看有没有通过数字几来选着的可能。

Func _Readini($zPath, $zCombo, $zKeyword)
        GUICtrlSetData($zCombo, '')
        Local $zOut = ''
        Local $aArray = IniReadSection($zPath, $zKeyword)
        If Not @error Then
                For $i = 1 To $aArray[0][0]
                        $zOut &= $aArray[$i][1] & '|'
                Next
                GUICtrlSetData($zCombo, $zOut, $aArray[1][1])
        EndIf
EndFunc   ;==>_Readini
发表于 2016-11-28 13:46:13 | 显示全部楼层
ControlCommand("标题", "文本", 控件ID, "SetCurrentSelection", 1)

试试吧
 楼主| 发表于 2016-11-28 14:29:28 | 显示全部楼层
回复 4# afan

A大,也许是我自己折腾错了,  这个发送命令的对自己编译的程序发送是没任何反应的。你看看下面的代码是不是哪里错了。

#include <GUIConstantsEx.au3>

Example()

Func Example()
        GUICreate("My GUI") ; will create a dialog box that when displayed is centered

        GUICtrlCreateCombo("", 10, 10)

        GUICtrlSetData(-1, "item1|item2|item3", "")
        Sleep(100)
        ControlCommand("My GUI", "", 'edit1', "SetCurrentSelection", 1)

        GUISetState(@SW_SHOW) ; will display an empty dialog box with a combo control with focus on

        ; Loop until the user exits.
        While 1
                Switch GUIGetMsg()
                        Case $GUI_EVENT_CLOSE
                                ExitLoop

                EndSwitch
        WEnd
EndFunc   ;==>Example
发表于 2016-11-28 16:05:56 | 显示全部楼层
我想是这样子:



本帖子中包含更多资源

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

×
发表于 2016-11-28 16:10:17 | 显示全部楼层
回复 6# chzj589

忘了上传附件:
Combo默认选中第一项

本帖子中包含更多资源

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

×
发表于 2016-11-28 16:13:22 | 显示全部楼层
回复 5# heroxianf


    控件id显然不是edit...
GUICreate("My GUI")
GUICtrlCreateCombo("", 10, 10)
GUICtrlSetData(-1, "item1|item2|item3", "")
ControlCommand("My GUI", "", 'ComboBox1', "SetCurrentSelection", 0)
GUISetState()
While 1
        Switch GUIGetMsg()
                Case -3
                        Exit
        EndSwitch
WEnd
 楼主| 发表于 2016-11-28 16:44:18 | 显示全部楼层
本帖最后由 heroxianf 于 2016-11-28 16:49 编辑

QQQ  终于搞明白了,  又学了个参数。

ControlCommand这个函数的选项真是搞不明白
发表于 2016-11-29 09:47:45 | 显示全部楼层
GUICreate("My GUI")
GUICtrlCreateCombo("", 10, 10)
GUICtrlSetData(-1, "item1|item2|item3", "item1")
GUISetState()
While 1
        Switch GUIGetMsg()
                Case -3
                        Exit
        EndSwitch
WEnd
搞那么复杂  无语
 楼主| 发表于 2016-11-29 10:19:08 | 显示全部楼层
回复 10# cfanpc


    是在不知道下拉菜单里有哪些的情况下选择的!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-28 21:25 , Processed in 0.097132 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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