Insére une chaîne dans la ListBox
#include <GuiListBox.au3>
_GUICtrlListBox_InsertString ( $hWnd, $sText [, $iIndex = -1] )
$hWnd | ID/handle du contrôle |
$sText | Chaîne de texte à insérer |
$iIndex | [optionnel] Spécifie l'index, compté à partir de 0, de la position à laquelle insérer la chaîne. Si ce paramètre est égal à -1, la chaîne est ajouté à la fin de la liste. |
Succès: | Retourne l'index, compté à partir de 0, de la position de l'élément. |
Échec: | Retourne -1. |
Si $iIndex est égal à -1, la chaîne est ajoutée à la fin de la liste. Contrairement à _GUICtrlListBox_AddString(), cette fonction ne nécessite pas une ListBox de style $LBS_SORT pour être triée.
_GUICtrlListBox_AddString, _GUICtrlListBox_DeleteString, _GUICtrlListBox_InitStorage
#include <GUIConstantsEx.au3> #include <GuiListBox.au3> #include <WindowsConstants.au3> Example() Func Example() Local $idListBox ; Crée une GUI GUICreate("List Box Insert String", 400, 296) $idListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($WS_BORDER, $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, "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.", 4) _GUICtrlListBox_UpdateHScroll($idListBox) _GUICtrlListBox_EndUpdate($idListBox) ; Boucle jusqu'à ce que l'utilisateur quitte. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example