Funktionreferenz


_GUICtrlListBox_FindString

Beschreibung anzeigen in

Sucht einen String

#include <GuiListBox.au3>
_GUICtrlListBox_FindString ( $hWnd, $sText [, $bExact = False] )

Parameter

$hWnd Control-ID / Handle des Controls
$sText zu suchender String
$bExact [optional] exakter Treffer oder Teiltreffer

Rückgabewert

Erfolg: 0-basierender Index des Items
Fehler: -1

Bemerkungen

Findet den ersten String in einer ListBox der mit dem gesuchten String beginnt.

Wenn $fExact = True, wird nach dem ersten ListBoxString gesucht, der exakt mit dem gesuchten String übereinstimmt, außer die Suche berücksichtigt nicht die Groß- und Kleinschreibung

- - - - - - - - Erklärung der Controls - - - - - - - -

Verwandte Funktionen

_GUICtrlListBox_FindInText, _GUICtrlListBox_SelectString

Beispiel

Beispiel 1

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

Beispiel()

Func Beispiel()
    Local $iIndex, $idListBox

    ; Erstellt eine GUI
    GUICreate("ListBox: Sucht einen String", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)

    GUISetState(@SW_SHOW)

    ; Fügt Strings hinzu
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Zufallstring", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_InsertString($idListBox, "eXaCt tExT", 3)
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Sucht nach einem Item
    $iIndex = _GUICtrlListBox_FindString($idListBox, "exa")
    _GUICtrlListBox_SetCurSel($idListBox, $iIndex)

    ; Die Schleife wiederholt sich, bis der Benutzer die Beenden-Aktion der GUI auslöst.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Beispiel

Beispiel 2

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

Example()

Func Example()
    Local $iIndex, $idListBox

    ; Erstellt eine GUI
    GUICreate("ListBox: Sucht einen exakten String", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)

    GUISetState(@SW_SHOW)

    ; Fügt Strings hinzu
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Zufallstring", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_InsertString($idListBox, "eXa", 2)
    _GUICtrlListBox_InsertString($idListBox, "eXaCt tExT", 3)
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Sucht nach einem Item
    $iIndex = _GUICtrlListBox_FindString($idListBox, "exact text", True)
    _GUICtrlListBox_SetCurSel($idListBox, $iIndex)

    ; Die Schleife wiederholt sich, bis der Benutzer die Beenden-Aktion der GUI auslöst.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example