By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

AutoIt GUICtrlCreateListView Function

The GUICtrlCreateListView is used to create a list in an AutoIt GUI.

Edited: 2015-01-15 22:07

The AutoIt GUICtrlCreateListView function is used to create a list with selectable items in an AutoIt GUI.

Tutorial: Creating a list with selectable items


textRequiredThe text of the column headings, separated by pipe "|" characters, or as specified by Opt("GUIDataSeparatorChar")
leftRequiredPosition from the left, in pixels.
topRequiredPosition from the top, in pixels.
widthOptionalThe width of the control, in pixels.
heightOptionalThe height of the control, in pixels.
styleOptionalControls the style of the window – See also: ListView Styles
ExStyleOptionalControls the extended style of the window – See also: ListView Extended Styles

GUICtrlCreateListView Example

 #include <GUIConstantsEx.au3>
 #include <ListviewConstants.au3>
 Opt("GUIOnEventMode", 1)


 ; ----- 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)
  GUICtrlCreateListViewItem("BlueBoden|782dF", $listview)

  $BtnSelect = GUICtrlCreateButton("Select", 100, 165, 80, 30)
  GUICtrlSetOnEvent(-1, "SelectItem")

  While 1
 ; ///// 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)
Func OnClose()