ListBox klicks

  • Hi,
    ich hab hier in einer GUI neben einigen Checkboxen und RadioButtons auch eine Listbox.
    Ich würde jetzt gerne bei einem Klick auf ein Element in dieser Listbox eine bestimmte Aktion ausführen.
    Kann mir jemand sagen wie ich sowas hinbekomme ?

    Einmal editiert, zuletzt von bordermax (23. Mai 2013 um 21:32)

    • Offizieller Beitrag
    Spoiler anzeigen
    [autoit]

    #Region - Timestamp
    ; 2013-05-23 19:50:08
    #EndRegion

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

    #include <GUIConstantsEx.au3>

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

    Opt('MustDeclareVars', 1)

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

    Example()

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

    Func Example()
    Local $MESSAGE = "1|2|3"
    Local $add, $clear, $mylist, $close, $msg

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

    GUICreate("My GUI list") ; will create a dialog box that when displayed is centered

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

    $add = GUICtrlCreateButton("Add", 64, 32, 75, 25)
    $clear = GUICtrlCreateButton("Clear", 64, 72, 75, 25)
    $mylist = GUICtrlCreateList("buttons that have been clicked", 176, 32, 121, 97)
    GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling
    GUICtrlSetData(-1, $MESSAGE)
    $close = GUICtrlCreateButton("my closing button", 64, 160, 175, 25)
    GUISetState()
    $msg = 0
    While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()

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

    Select
    Case $msg = $add
    GUICtrlSetData($mylist, "You clicked button No1|")
    Case $msg = $clear
    GUICtrlSetData($mylist, "")
    Case $msg = $mylist
    MsgBox(0, "Hallo ", "Du hast die Listbox angeklickt." & @CRLF & GUICtrlRead($mylist) & " ist gerade selektiert", 2)
    Case $msg = $close
    Exit
    EndSelect
    WEnd
    EndFunc ;==>Example

    [/autoit]

    Edit: Mit direkter Auswahl:

    Spoiler anzeigen
    [autoit]

    #region - Timestamp
    ; 2013-05-23 19:55:55
    #endregion - Timestamp

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

    #include <GUIConstantsEx.au3>

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

    Opt('MustDeclareVars', 1)

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

    Example()

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

    Func Example()
    Local $MESSAGE = "1|2|3"
    Local $add, $clear, $mylist, $close, $msg

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

    GUICreate("My GUI list") ; will create a dialog box that when displayed is centered
    $mylist = GUICtrlCreateList("", 176, 32, 121, 97)
    GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling
    GUICtrlSetData(-1, $MESSAGE)
    $close = GUICtrlCreateButton("my closing button", 64, 160, 175, 25)
    GUISetState()
    $msg = 0
    While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()

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

    Select
    Case $msg = $mylist
    MsgBox(0, "Hallo ", "Du hast die Listbox angeklickt.", 1)
    Switch GUICtrlRead($mylist)
    Case "1"
    MsgBox(0, "Aktion", 'Hier ist die Aktion für den ListBox Eintrag "1"')
    Case "2"
    MsgBox(0, "Aktion", 'Hier ist die Aktion für den ListBox Eintrag "2"')
    Case "3"
    MsgBox(0, "Aktion", 'Hier ist die Aktion für den ListBox Eintrag "3"')
    EndSwitch
    Case $msg = $close
    Exit
    EndSelect
    WEnd
    EndFunc ;==>Example

    [/autoit]