Insert a string into the list
#include <GuiListBox.au3>
_GUICtrlListBox_InsertString($hWnd, $sText [, $iIndex = -1])
| $hWnd | Control ID/Handle to the control |
| $sText | Text string to be inserted |
| $iIndex | [optional] Specifies the zero based index of the position at which to insert the string. If this parameter is -1 the string is added to the end of the list. |
| Success: | Zero based index of the item position |
| Failure: | -1 |
#include <GuiListBox.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Debug_LB = False ; Check ClassName being passed to ListBox functions, set to True and use a handle to another control to see it work
_Main()
Func _Main()
Local $hListBox
; Create GUI
GUICreate("List Box Insert String", 400, 296)
$hListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($WS_BORDER, $LBS_NOTIFY, $LBS_DISABLENOSCROLL, $WS_HSCROLL))
GUISetState()
; Add strings
_GUICtrlListBox_BeginUpdate($hListBox)
For $iI = 1 To 9
_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
Next
_GUICtrlListBox_InsertString($hListBox, "Let's add one really long line of text so that we can set the horizontal scroll bar and " & _
"show that, unless we dynamically update the scroll bar, it won't show the full line.", 4)
_GUICtrlListBox_UpdateHScroll($hListBox)
_GUICtrlListBox_EndUpdate($hListBox)
; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main