Combo und SetData

    • Offizieller Beitrag

    Eigentlich wird der Standardwert beibehalten.

    [autoit]

    #include <GUIConstantsEx.au3>

    [/autoit][autoit][/autoit][autoit]

    Opt('MustDeclareVars', 1)

    [/autoit][autoit][/autoit][autoit]

    Example()

    [/autoit][autoit][/autoit][autoit]

    Func Example()
    Local $msg,$Combo
    GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered

    [/autoit][autoit][/autoit][autoit]

    $Combo= GUICtrlCreateCombo("item1", 10, 10) ; create first item
    GUICtrlSetData(-1, "item2|item3", "item3") ; add other item snd set a new default

    [/autoit][autoit][/autoit][autoit]

    GUISetState()
    GUICtrlSetData($Combo, "item4|item5")

    [/autoit][autoit][/autoit][autoit]

    ; Run the GUI until the dialog is closed
    While 1
    $msg = GUIGetMsg()

    [/autoit][autoit][/autoit][autoit]

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    EndFunc ;==>Example

    [/autoit]


    Nach einfügen von Item4 und Item5 ist weiterhin Item3 selektiert.

    • Offizieller Beitrag

    Benutze einfach ControlCommand anstatt GUICtrlSetData.

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt('MustDeclareVars', 1)

    [/autoit] [autoit][/autoit] [autoit]

    Example()

    [/autoit] [autoit][/autoit] [autoit]

    Func Example()
    Local $msg, $Combo
    GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered

    [/autoit] [autoit][/autoit] [autoit]

    $Combo = GUICtrlCreateCombo("item1", 10, 10) ; create first item
    GUICtrlSetData(-1, "item2|item3", "item3") ; add other item snd set a new default

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()
    GUICtrlSetData($Combo, "item4|item5")
    ControlCommand("My GUI combo", "", $Combo, "SelectString", 'item5')
    ; Run the GUI until the dialog is closed
    While 1
    $msg = GUIGetMsg()

    [/autoit] [autoit][/autoit] [autoit]

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    EndFunc ;==>Example

    [/autoit]
  • @Rapi: das geht doch mit GiCtrlSetData mind. genauso einfach:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt('MustDeclareVars', 1)

    [/autoit] [autoit][/autoit] [autoit]

    Example()

    [/autoit] [autoit][/autoit] [autoit]

    Func Example()
    Local $msg,$Combo, $Button
    GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered

    [/autoit] [autoit][/autoit] [autoit]

    $Combo= GUICtrlCreateCombo("item1", 10, 10) ; create first item
    GUICtrlSetData(-1, "item2|item3", "item3") ; add other item snd set a new default
    $Button = GUICtrlCreateButton("&Standard 4",10,120)
    GUISetState()
    GUICtrlSetData($Combo, "item4|item5")

    [/autoit] [autoit][/autoit] [autoit]

    ; Run the GUI until the dialog is closed
    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button
    GUICtrlSetData($Combo,"item4")
    EndSwitch
    WEnd
    EndFunc ;==>Example

    [/autoit]

    mfg autoBert