AutoIt GUICtrlCreateListView Function
How to use the AutoIt GUICreateListView function to create a list with selectable items.
1930 views
Edited: 2019-01-10 17:16
The AutoIt GUICtrlCreateListView function is used to create a list with selectable items in AutoIt GUIs.
Parameters
text | Required | The text of the column headings, separated by pipe "|" characters, or as specified by Opt("GUIDataSeparatorChar") |
left | Required | Position from the left, in pixels. |
top | Required | Position from the top, in pixels. |
width | Optional | The width of the control, in pixels. |
height | Optional | The height of the control, in pixels. |
style | Optional | Controls the style of the window – See also: ListView Styles |
ExStyle | Optional | Controls the extended style of the window – See also: ListView Extended Styles |
Example
#include <GUIConstantsEx.au3> #include <ListviewConstants.au3> Opt("GUIOnEventMode", 1) MainGUI() ; ----- GUIs Func MainGUI() Global $listview $listGUI = GUICreate("AutoIt GUICtrlCreateListView Example", 400, 200, 100, 200, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "OnClose") $listview = GUICtrlCreateListView("Username|Password", 10, 10, 200, 150, $LVS_NOSORTHEADER+$LVS_SINGLESEL,$LVS_EX_GRIDLINES) GUICtrlCreateListViewItem("John|1234", $listview) GUICtrlCreateListViewItem("AutoItUser|153_4", $listview) $BtnSelect = GUICtrlCreateButton("Select", 100, 165, 80, 30) GUICtrlSetOnEvent(-1, "SelectItem") GUISetState() While 1 Sleep(10) WEnd EndFunc ; ///// Functions Func SelectItem() $sItem = GUICtrlRead(GUICtrlRead($listview)) $sItem = StringTrimRight($sItem, 1) ; Will remove the pipe "|" from the end of the string MsgBox(0, "Selected Item", $sItem) EndFunc Func OnClose() Exit EndFunc
Tell us what you think: