Select one or more consecutive items in a multiple-selection list box
#include <GuiListBox.au3>
_GUICtrlListBox_SelItemRangeEx ( $hWnd, $iFirst, $iLast )
$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 |
Success: | True. |
Failure: | False. |
If the $iFirst is less than the $iLast, the specified range of items is selected.
If $iFirst is greater than or equal to $iLast, the range is removed from the specified range of items.
To select only one item, select two items and then deselect the unwanted item.
Use this message only with multiple-selection list boxes.
This message can select a range only within the first 65,536 items.
#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
Example()
Func Example()
Local $sText, $idListBox
; Create GUI
GUICreate("List Box Sel Item RangeEx", 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_SelItemRangeEx($idListBox, 3, 5)
; Loop until the user exits.
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>Example