Insert a string
#include <GuiComboBox.au3>
_GUICtrlComboBox_InsertString ( $hWnd, $sText [, $iIndex = -1] )
$hWnd | Control ID/Handle to the control |
$sText | Text string to be inserted |
$iIndex | [optional] Specifies the 0-based index of the position at which to insert the string. |
Success: | a 0-based index of the position at which the string was inserted. |
Failure: | -1. |
If the $iIndex parameter is –1, the string is added to the end of the list.
If the ComboBox has $WS_HSCROLL style and you insert a string wider than the ComboBox, you should use the _GUICtrlComboBox_SetHorizontalExtent() function to ensure the horizontal scrollbar appears.
_GUICtrlComboBox_AddString, _GUICtrlComboBox_InitStorage, _GUICtrlComboBox_SetHorizontalExtent
#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
Example()
Func Example()
Local $idCombo
; Create GUI
GUICreate("ComboBox Insert String", 400, 296)
$idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
GUISetState(@SW_SHOW)
; Add files
_GUICtrlComboBox_BeginUpdate($idCombo)
_GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
_GUICtrlComboBox_EndUpdate($idCombo)
; Insert string
_GUICtrlComboBox_InsertString($idCombo, "Some Inserted string", 0)
; Loop until the user exits.
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>Example