Function Reference


_GUICtrlListBox_SelItemRange

Select one or more consecutive items in a multiple-selection list box

#include <GuiListBox.au3>
_GUICtrlListBox_SelItemRange ( $hWnd, $iFirst, $iLast [, $bSelect = True] )

Parameters

$hWnd Control ID/Handle to the control
$iFirst 0-based index of the first item to select
$iLast 0-based index of the last item to select
$bSelect [optional] Specifies how to set the selection.
If this parameter is True, the string is selected and highlighted.
If it is False, the highlight is removed and the string is no longer selected.

Return Value

Success: True.
Failure: False.

Remarks

Use this message only with multiple-selection list boxes.
This message can select a range only within the first 65,536 items.

Related

_GUICtrlListBox_SelItemRangeEx

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>

Example()

Func Example()
        Local $sText, $idListBox

        ; Create GUI
        GUICreate("List Box Sel Item Range", 400, 296)
        $idListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL))
        GUISetState(@SW_SHOW)

        ; Add strings
        _GUICtrlListBox_BeginUpdate($idListBox)
        For $iI = 1 To 10
                $sText = StringFormat("%03d : Random string ", Random(1, 100, 1))
                For $iX = 1 To Random(1, 20, 1)
                        $sText &= Chr(Random(65, 90, 1))
                Next
                _GUICtrlListBox_AddString($idListBox, $sText)
        Next
        _GUICtrlListBox_EndUpdate($idListBox)

        ; Select a few items
        _GUICtrlListBox_SelItemRange($idListBox, 3, 5)

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