Sucht nach einem Item, welches mit dem festgelegten String beginnt
#include <GuiListBox.au3>
_GUICtrlListBox_SelectString ( $hWnd, $sText [, $iIndex = -1] )
$hWnd | Control-ID / Handle des Controls |
$sText | String der den zu suchenden String enthält. |
$iIndex | [optional] legt den 0-basierenden Index des Items fest bei dem die Suche beginnen soll. Wenn die Suche das Ende der Listbox erreicht, wird sie oben am Anfang der Listbox bis zu dem festgelegten Item von $iIndex fortgesetzt. Falls $iIndex –1 ist, wird die komplette Listbox vom Anfang an durchsucht. |
Erfolg: | Der 0-basierende Index des ausgewählten Items |
Fehler: | -1 |
Die Listbox wird falls notwendig so gescrollt, dass das markierte Item sichtbar ist-
Diese Funktion ist nicht zu verwenden, wenn die Listbox den Stil $LBS_MULTIPLESEL oder $LBS_EXTENDEDSEL besitzt.
- - - - - - - - Erklärung der Controls - - - - - - - -
_GUICtrlListBox_FindInText, _GUICtrlListBox_FindString
#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>
Example()
Func Example()
Local $sText, $idListBox
; Erstellt eine GUI
GUICreate("ListBox: String auswählen", 400, 296)
$idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
GUISetState(@SW_SHOW)
; Fügt Strings hinzu
_GUICtrlListBox_BeginUpdate($idListBox)
For $iI = 1 To 10
$sText = StringFormat("%03d : Zufallstring ", 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_AddString($idListBox, "020 : Zielstring")
_GUICtrlListBox_EndUpdate($idListBox)
; String auswählen
MsgBox($MB_SYSTEMMODAL, "Information", "Index des Zielstrings: " & _GUICtrlListBox_SelectString($idListBox, "020 : Z"));
; Die Schleife wiederholt sich, bis der Benutzer die Beenden-Aktion der GUI auslöst.
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>Example