函数参考


GUICtrlSetData

修改指定控件的数据.

GUICtrlSetData ( 控件ID, 数据 [, 默认值] )

参数

控件ID 控件标识符(控件ID),可由 GUICtrlCreate... 函数的返回值获得.
数据 对于 Combo (列表框), List (列表), ListView (列表查看), ListViewItem (列表查看项目): 由 Opt("GUIDataSeparatorChar",...) 分开的项目文本,默认使用"|"分开.
对于 Progress (进度条): 百分比
对于 Slider (滑动条): 值
对于 Group (群组), Label (标签), Button (按钮), Checkbox (检查框), Radio (单选框), Combo (组合框), List (列表), Input (输入框), Edit (编辑框), TabItem (标签项目), TreeViewItem(树形列表项目): 替换文本
对于 Date (日期): 日期或时间,具体取决于控件样式和系统区域设置
对于 Dummy : 值.
默认值 [可选参数] 对于 Combo (组合框), List (列表): 默认值.
对于 Edit (编辑框), Input (输入框): 若此参数有定义而且不是 "" 则参数"数据"所含字符串将被插入到当前插入点后(并非覆盖原有内容).

返回值

成功: 返回 1.
失败: 返回 0.
返回值为 -1,说明给定的数据无效.

注意/说明

For Combo or List control :
If the "data" corresponds to an already existing entry it is set as the default.
If the "data" starts with GUIDataSeparatorChar or is an empty string "" the previous list is destroyed.

For ListView, ListViewItem controls :
To update a specific column just forget about the others ie "||update" to update 3rd column.
If "update" is empty the column/subitem will be erased. For example "|" will erase the second column/subitem, "" will erase the first.

For Monthcal controls :
The "data" date format is "yyyy/mm/dd".

For Date controls:
The date and time is in the format defined by the regional settings. GuiCtrlRead() use the same default format.

相关

GUICtrlCreate..., GUICtrlUpdate..., GUICtrlRead, GUIDataSeparatorChar (Option)

示例/演示


#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $msg

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

    GUICtrlCreateCombo("", 10, 10)

    GUICtrlSetData(-1, "item1|item2|item3", "item3")

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

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()

        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   ;==>Example