Wählt einen String in der Liste einer ComboBox aus
#include <GuiComboBox.au3>
_GUICtrlComboBox_SetCurSel ( $hWnd [, $iIndex = -1] )
$hWnd | Control-ID / Handle des Controls |
$iIndex | [optional] legt den auszuwählenden 0-basierenden Index des Strings fest |
Erfolg: | Der ausgewählte Index des Items |
Fehler: | -1 |
Falls der $iIndex –1 ist, wird jede Markierung in der Liste entfernt und das Edit-Control wird geleert.
Falls $iIndex größer als die Anzahl der Items in der Liste ist oder falls $iIndex –1 ist, wird -1 zurückgegeben und die Markierung wird entfernt.
- - - - - - - - Erklärung der Controls - - - - - - - -
#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
Example()
Func Example()
; Erstellt eine GUI
GUICreate("ComboBox: Ermittelt die aktuelle Auswahl (v" & @AutoItVersion & ")", 500, 296)
Local $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
GUISetState(@SW_SHOW)
; Fügt Dateien hinzu
_GUICtrlComboBox_BeginUpdate($idCombo)
_GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
_GUICtrlComboBox_EndUpdate($idCombo)
; Wählt ein Item aus
_GUICtrlComboBox_SetCurSel($idCombo, 2)
; Ermittelt die aktuelle Auswahl
MsgBox($MB_SYSTEMMODAL, "Information", "aktuelle Auswahl: " & _GUICtrlComboBox_GetCurSel($idCombo))
; Die Schleife wiederholt sich, bis der Benutzer die Beenden-Aktion der GUI auslöst.
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>Example