Ajoute une chaîne
#include <GuiListBox.au3>
_GUICtrlListBox_AddString ( $hWnd, $sText )
$hWnd | ID/handle du contrôle |
$sText | Chaîne qui doit être ajoutée |
Succès: | Retourne l'index de la chaîne, compté à partir de 0. |
Échec: | Retourne -1. |
Si l'espace est insuffisant pour stocker la nouvelle chaîne, la valeur de retour est $LB_ERRSPACE.
Si la ListBox n'a pas le style $LBS_SORT, la chaîne est ajoutée à la fin de la liste.
Sinon, la chaîne est inséré dans la liste et la liste est triée.
_GUICtrlListBox_AddFile, _GUICtrlListBox_DeleteString, _GUICtrlListBox_InitStorage, _GUICtrlListBox_InsertString
#include <GUIConstantsEx.au3> #include <GuiListBox.au3> #include <WindowsConstants.au3> Example() Func Example() Local $idListBox ; Crée une GUI GUICreate("List Box Add String", 400, 296) $idListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_DISABLENOSCROLL, $WS_HSCROLL)) 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_InsertString($idListBox, "This is the string that we're looking for", 6) _GUICtrlListBox_InsertString($idListBox, _ "Let's add one really long line of text so that we can set the horizontal scroll bar and " & _ "show that, unless we dynamically update the scroll bar, it won't show the full line.", 9) _GUICtrlListBox_UpdateHScroll($idListBox) _GUICtrlListBox_EndUpdate($idListBox) ; Boucle jusqu'à ce que l'utilisateur quitte. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example