Searches the ListBox of a ComboBox for an item that begins with the characters in a specified string
#include <GuiComboBox.au3>
_GUICtrlComboBox_SelectString ( $hWnd, $sText [, $iIndex = -1] )
$hWnd | Control ID/Handle to the control |
$sText | String that contains the characters for which to search |
$iIndex | [optional] Specifies the 0-based index of the item preceding the first item to be searched |
Success: | the index of the selected item. |
Failure: | -1. |
When the search reaches the bottom of the list, it continues from the top of the list back to the item specified by the wParam parameter.
If $iIndex is –1, the entire list is searched from the beginning.
A string is selected only if the characters from the starting point match the characters in the prefix string
If a matching item is found, it is selected and copied to the edit control.
_GUICtrlComboBox_FindString, _GUICtrlComboBox_FindStringExact, _GUICtrlComboBoxEx_FindStringExact
#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
Example()
Func Example()
Local $idCombo
; Create GUI
GUICreate("ComboBox Select String", 400, 296)
$idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296, BitOR($CBS_SIMPLE, $CBS_DISABLENOSCROLL, $WS_VSCROLL))
GUISetState(@SW_SHOW)
; Add files
_GUICtrlComboBox_BeginUpdate($idCombo)
_GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
; Add string
_GUICtrlComboBox_AddString($idCombo, "This string has been added")
; Add files
_GUICtrlComboBox_AddDir($idCombo, "", $DDL_DRIVES, False)
_GUICtrlComboBox_EndUpdate($idCombo)
; select string
_GUICtrlComboBox_SelectString($idCombo, "This")
; Loop until the user exits.
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>Example