Function Reference


_GUICtrlListBox_DeleteString

Delete a string

#include <GuiListBox.au3>
_GUICtrlListBox_DeleteString($hWnd, $iIndex)

Parameters

$hWnd Control ID/Handle to the control
$iIndex Zero-based index of the string to be deleted

Return Value

Success: Count of strings remaining
Failure: -1

Remarks

None.

Related

_GUICtrlListBox_AddString, _GUICtrlListBox_InsertString, _GUICtrlListBox_AddFile, _GUICtrlListBox_ResetContent

Example


#include <GuiListBox.au3>
#include <GUIConstantsEx.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 Delete String", 400, 296)
    $hListBox = GUICtrlCreateList("", 2, 2, 396, 296)

    GUISetState()

    ; Add strings
    _GUICtrlListBox_BeginUpdate($hListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($hListBox, StringFormat("%d : List box string", $iI))
    Next
    _GUICtrlListBox_EndUpdate($hListBox)

    ; Delete middle string
    _GUICtrlListBox_DeleteString($hListBox, 4)

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main