Listview Items durchblättern

  • Hi,

    ich habe im Moment ein Problem mit einer Listview.
    Undzwar baue ich mir die Listview wie folgt zusammen:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #include <Array.au3>

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

    Dim $array[3][2]
    $array[0][0] = "a"
    $array[0][1] = "a2"
    $array[1][0] = "b"
    $array[1][1] = "b2"
    $array[2][0] = "c"
    $array[2][1] = "c2"
    _ArrayDisplay( $array, "Whole array" )

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

    GUICreate("bla",700,700)
    GUISetState (@SW_SHOW)

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

    $listview = GUICtrlCreateListView ("Spalte1|Spalte2",20,30,200,150)
    For $i = 0 To UBound($array) -1
    $item=GUICtrlCreateListViewItem($array[$i][0] & "|" & $array[$i][1],$listview)
    GUICtrlSetData(-1,$item)
    Next
    $button = GUICtrlCreateButton ("next element",75,500,70,20)
    Do
    $msg = GUIGetMsg ()
    Select
    Case $msg = $button
    $a=GUICtrlRead(GUICtrlRead($listview))
    MsgBox(0,"ausgabe",$a)
    EndSelect
    Until $msg = $GUI_EVENT_CLOSE

    [/autoit]


    Ich wollte jetzt mit dem Button jedes Element durchschalten in der Listview. Also erst wird a|a2 ausgegeben,
    dann b|b2 usw. Leider finde ich keinen Ansatz wie ich das realisieren könnte. Ich hoffe mir kann einer helfen.

    MfG
    EP2

    Einmal editiert, zuletzt von EP2 (21. Oktober 2009 um 18:07)

    • Offizieller Beitrag

    So:

    Spoiler anzeigen
    [autoit]


    #Include <GuiListView.au3>
    #include <GUIConstants.au3>
    #include <Array.au3>

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

    Dim $array[3][2]
    $array[0][0] = "a"
    $array[0][1] = "a2"
    $array[1][0] = "b"
    $array[1][1] = "b2"
    $array[2][0] = "c"
    $array[2][1] = "c2"
    ;~ _ArrayDisplay($array, "Whole array")

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

    $gui = GUICreate("bla", 700, 700)
    GUISetState(@SW_SHOW)
    $index = 0
    $listview = GUICtrlCreateListView("Spalte1|Spalte2", 20, 30, 200, 150)
    For $i = 0 To UBound($array) - 1
    GUICtrlCreateListViewItem($array[$i][0] & "|" & $array[$i][1], $listview)
    Next
    $button = GUICtrlCreateButton("next element", 75, 500, 90, 30)
    Do
    $msg = GUIGetMsg()
    Select
    Case $msg = $button
    $read = _GUICtrlListView_GetItemTextString($listview, $index)
    MsgBox(0, "ausgabe", $read)
    $index += 1
    If $index >= _GUICtrlListView_GetItemCount($listview) Then $index = 0
    EndSelect
    Until $msg = $GUI_EVENT_CLOSE

    [/autoit]
  • Super :) Du bist mein Mann!!

    Hab die Funktion garnicht gefunden. Ich sollte mir die Hilfe mal besser anschauen. Danke dir für diese schnelle Hilfe.


    Gruß
    EP2

  • Hallo EP2,

    eine der Möglichkeiten:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #Include <GuiListView.au3>
    #include <Array.au3>

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

    Dim $array[3][2]
    $array[0][0] = "a"
    $array[0][1] = "a2"
    $array[1][0] = "b"
    $array[1][1] = "b2"
    $array[2][0] = "c"
    $array[2][1] = "c2"
    _ArrayDisplay( $array, "Whole array" )

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

    GUICreate("bla",700,700)
    GUISetState (@SW_SHOW)

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

    $listview = GUICtrlCreateListView ("Spalte1|Spalte2",20,30,200,150)
    For $i = 0 To UBound($array) -1
    $item=GUICtrlCreateListViewItem($array[$i][0] & "|" & $array[$i][1],$listview)
    GUICtrlSetData(-1,$item)
    Next
    $button = GUICtrlCreateButton ("next element",75,500,70,20)
    Do
    $msg = GUIGetMsg ()
    Select
    Case $msg = $button
    For $i = 1 to _GUICtrlListView_GetItemCount($listview)
    $a = _GUICtrlListView_GetItemTextArray($listview,$i-1)
    for $j = 1 to $a[0]
    MsgBox(0,"Item : " & $i+1 & "Col : " & $j,$a[$j])
    Next
    Next

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

    ; $a=GUICtrlRead(GUICtrlRead($listview)) ;<========= GuiCtrlRead ergibt die ID des aktuell slecktierte Items
    ; MsgBox(0,"ausgabe",$a)
    EndSelect
    Until $msg = $GUI_EVENT_CLOSE

    [/autoit]