Listview

  • hallo,
    ich möchte gern aus ListView das, was in der ersten spalte steht rausholen, nur bei stringsplit kommt immer eine 1 oder 3 raus
    hier ein beispiel:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>

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

    GUICreate("")
    $list = GUICtrlCreateListView("text1|text2",0,0)
    GUICtrlCreateListViewItem("test1| bufu",$list)
    GUICtrlCreateListViewItem("test2| jaja",$list)
    $bttn = GUICtrlCreateButton("test",200,0)
    GUISetState()
    while 1
    $msg = GUIGetMsg()
    Switch $msg
    case $bttn
    $read = GUICtrlRead(GUICtrlRead($list))
    MsgBox(0,"",$read)
    $split = StringSplit($read,"|")
    MsgBox(0,"",$split[0])
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd

    [/autoit]


    wenn jemand weiter weiss wäre ich dankbar für die hilfe ^^

    Mfg. PCKing


    Mein PC

    CPU: AMD FX 8350 8x4.00GHz
    Ram: 8GB DDR3
    Grafikkarte: Nvidia Geforce GTX 960 (4GB)
    Festplatten: 500GB SSD 1TB HDD
    Laufwerk: Blueray RW+ Brenner

  • Spoiler anzeigen
    [autoit]


    #include <GUIConstantsEx.au3>

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

    GUICreate("")
    $list = GUICtrlCreateListView("text1|text2",0,0)
    GUICtrlCreateListViewItem("test1| bufu",$list)
    GUICtrlCreateListViewItem("test2| jaja",$list)
    $bttn = GUICtrlCreateButton("test",200,0)
    GUISetState()
    while 1
    $msg = GUIGetMsg()
    Switch $msg
    case $bttn
    $read = GUICtrlRead(GUICtrlRead($list))
    MsgBox(0,"",$read)
    $split = StringSplit($read,"|")
    MsgBox(0,"","Item's count: " &$split[0])
    MsgBox(0,"","1. Item: " &$split[1])
    MsgBox(0,"","2. Item: " &$split[2])
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd

    [/autoit]


    :D

  • Stringsplit gibt nämlich im ersten Arrayelement die Anzahl der gefundenen / geteilten Strings zurück.

    Hier ein Auszug aus der Hilfe:

    Zitat

    Gibt ein Array zurück. Standardmäßg ist enthält das erste Element ($array[0]) die Anzahl des zurückgegebenen Teilstrings. Die weiteren Elemente ($array[1], $array[2], etc.) enthalten den Teilstring des aufgeteilten Strings.
    Falls das Flag = 2 ist, wird die Anzahl nicht in dem ersten Element enthalten sein.

  • Spoiler anzeigen


    Return Value
    Returns an array, the first element ($array[0]) contains the number of strings returned, the remaining elements ($array[1], $array[2], etc.) contain the delimited strings.
    If no delimiters were found @error is set to 1, the count is 1 ($array[0]) and the full string is returned ($array[1]).

    Remarks
    If you use a blank string "" for the delimiters, each character will be returned as an element.
    If the delimiter you wish to use is a substring instead of individual single characters, see the example below.
    StringSplit is very useful as an alternative to StringInStr and as a means to populate an array.
    Caution if you use the macro @CRLF you are referring to a 2 character string so you will generate extra blanks lines.

    Nochmal zur Erklärung ;)

    Wie Seubo schneller war :rolleyes:

  • O.o mann bin ich dumm, da hätt ich eigentlich auch selber drauf kommen können!!! ich glaub ich bin einfach zu müde :sleeping:
    thx für für die hilfe :D

    Mfg. PCKing


    Mein PC

    CPU: AMD FX 8350 8x4.00GHz
    Ram: 8GB DDR3
    Grafikkarte: Nvidia Geforce GTX 960 (4GB)
    Festplatten: 500GB SSD 1TB HDD
    Laufwerk: Blueray RW+ Brenner