UDF > GUI > GuiListBox >


_GUICtrlListBox_FindString

Recherche une cha�ne

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

Param�tres

$hWnd ID/handle du contr�le
$sText Cha�ne � rechercher
$bExact [optionnel] Correspondance exacte ou pas

Valeur de retour

Succ�s: Retourne l'index de l'�l�ment, compt� � partir de 0.
�chec: Retourne -1.

Remarques

Trouve la premi�re cha�ne de la ListBox qui commence par la cha�ne sp�cifi�e.

Si $bExact est activ�, trouve la premi�re cha�ne de la ListBox qui correspond exactement � la cha�ne sp�cifi�e, sauf que la recherche n'est pas sensible � la casse.

En relation

_GUICtrlListBox_FindInText, _GUICtrlListBox_SelectString

Exemple

Exemple 1

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

Example()

Func Example()
    Local $iIndex, $idListBox

    ; Cr�e une GUI
    GUICreate("List Box Find String", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)

    GUISetState(@SW_SHOW)

    ; Ajoute des cha�nes
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_InsertString($idListBox, "eXaCt tExT", 3)
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Trouve un �l�ment
    $iIndex = _GUICtrlListBox_FindString($idListBox, "exa")
    _GUICtrlListBox_SetCurSel($idListBox, $iIndex)

    ; Boucle jusqu'� ce que l'utilisateur quitte.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Exemple 2

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

Example()

Func Example()
    Local $iIndex, $idListBox

    ; Cr�e une GUI
    GUICreate("List Box Find String Exact", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)

    GUISetState(@SW_SHOW)

    ; Ajoute des cha�nes
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_InsertString($idListBox, "eXa", 2)
    _GUICtrlListBox_InsertString($idListBox, "eXaCt tExT", 3)
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Trouve un �l�ment
    $iIndex = _GUICtrlListBox_FindString($idListBox, "exact text", True)
    _GUICtrlListBox_SetCurSel($idListBox, $iIndex)

    ; Boucle jusqu'� ce que l'utilisateur quitte.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example