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 ?
ListBox klicks
-
- [ gelöst ]
-
bordermax -
23. Mai 2013 um 17:32 -
Geschlossen -
Erledigt
-
-
- Offizieller Beitrag
Spoiler anzeigen
[autoit]#Region - Timestamp
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
; 2013-05-23 19:50:08
#EndRegion#include <GUIConstantsEx.au3>
[/autoit] [autoit][/autoit] [autoit]Opt('MustDeclareVars', 1)
[/autoit] [autoit][/autoit] [autoit]Example()
[/autoit] [autoit][/autoit] [autoit]Func Example()
[/autoit] [autoit][/autoit] [autoit]
Local $MESSAGE = "1|2|3"
Local $add, $clear, $mylist, $close, $msgGUICreate("My GUI list") ; will create a dialog box that when displayed is centered
[/autoit] [autoit][/autoit] [autoit]$add = GUICtrlCreateButton("Add", 64, 32, 75, 25)
[/autoit] [autoit][/autoit] [autoit]
$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()Select
[/autoit]
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 ;==>ExampleEdit: Mit direkter Auswahl:
Spoiler anzeigen
[autoit]#region - Timestamp
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
; 2013-05-23 19:55:55
#endregion - Timestamp#include <GUIConstantsEx.au3>
[/autoit] [autoit][/autoit] [autoit]Opt('MustDeclareVars', 1)
[/autoit] [autoit][/autoit] [autoit]Example()
[/autoit] [autoit][/autoit] [autoit]Func Example()
[/autoit] [autoit][/autoit] [autoit]
Local $MESSAGE = "1|2|3"
Local $add, $clear, $mylist, $close, $msgGUICreate("My GUI list") ; will create a dialog box that when displayed is centered
[/autoit] [autoit][/autoit] [autoit]
$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()Select
[/autoit]
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 -
Danke, passt !!