Kleines Problem bei einer Listview

  • Hallo
    Ich bräuchte mal kurz ein klein wenig hilfe.
    Bei dem einfügen eines mehrzeiligen Kommentares in der zweiten GUI
    soll der Kommentar in der Listview mehrzeilig angezeigt werden und nicht im "Datum" oder
    "Verfasser" Feld stehen.
    Irgendwie bekomme ich es einfach nicht hin - kann mir einer helfen?

    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiListView.au3>
    #include <ListViewConstants.au3>
    #include <WindowsConstants.au3>
    #include <EditConstants.au3>

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

    $sHeader = "Datum|Verfasst von|Kommentar / Verbesserungsvorschlag"
    $sDBFile = @ScriptDir & "\Kommentar - Verbesserung.txt"
    $iEdit = -1
    $Form1 = GUICreate("Kommentar / Verbesserungsvorschlag", 800, 500)
    $Liste1 = GUICtrlCreateListView("Datum|Verfasst von|Kommentar / Verbesserungsvorschlag",0 ,0 ,1000, 450)
    $hLVHandle = GUICtrlGetHandle($Liste1)
    _GUICtrlListView_SetColumn($hLVHandle, 0, "Datum", 75, 0)
    _GUICtrlListView_SetColumn($hLVHandle, 1, "Verfasst von", 120, 0)
    _GUICtrlListView_SetColumn($hLVHandle, 2, "Kommentar / Verbesserungsvorschlag", 800, 0, $ES_MULTILINE + $ES_WANTRETURN)

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

    $Eintragen = GUICtrlCreateButton("Kommentar / Verbesserungsvorschlag verfassen", 250, 455, 300, 40)
    $hCMenu = GUICtrlCreateContextMenu($Liste1)
    $hCEintragen = GUICtrlCreateMenuItem("Kommentar / Verbesserungsvorschlag verfassen", $hCMenu)
    GUISetState(@SW_SHOW, $Form1)

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

    $Form2 = GUICreate("Kommentar / Verbesserungsvorschlag verfassen", 500, 400)
    $Lable1 = GUICtrlCreateLabel("Datum", 20, 20, 100, 20)
    $Input1 = GUICtrlCreateInput("", 20, 40, 100, 20)
    $Lable2 = GUICtrlCreateLabel("Verfasser", 150, 20, 150, 20)
    $Input2 = GUICtrlCreateInput("", 150, 40, 150, 20)
    $Lable3 = GUICtrlCreateLabel("Kommentar / Verbesserungsvorschlag", 20, 80, 460, 20)
    $Input3 = GUICtrlCreateInput("", 20, 100, 460, 245, $ES_MULTILINE + $ES_WANTRETURN)
    $Button1 = GUICtrlCreateButton("Eintrag speichern", 150, 350, 200, 40)

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

    If FileExists($sDBFile) Then Load()
    While 1
    $msg = GUIGetMsg(1)
    Switch $msg[1]
    Case $Form1
    Switch $msg[0]
    Case $GUI_EVENT_CLOSE
    Save()
    If MsgBox(32 + 4, "Beenden", "Wollen sie das Programm wirklich beenden?") = 6 Then ExitLoop
    Case $Eintragen, $hCEintragen
    GUISetState(@SW_DISABLE, $Form1)
    GUISetState(@SW_SHOW, $Form2)
    EndSwitch
    Case $Form2
    Switch $msg[0]
    Case $Button1
    GUICtrlCreateListViewItem(GUICtrlRead($Input1) & "|" & GUICtrlRead($Input2) & "|" & GUICtrlRead($Input3), $Liste1)
    GUICtrlSetData($Input1, "")
    GUICtrlSetData($Input2, "")
    GUICtrlSetData($Input3, "")
    GUISetState(@SW_ENABLE, $Form1)
    GUISetState(@SW_HIDE, $Form2)
    Case $GUI_EVENT_CLOSE
    GUISetState(@SW_ENABLE, $Form1)
    GUISetState(@SW_HIDE, $Form2)
    EndSwitch
    EndSwitch
    WEnd

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

    Func Load()
    Local $hFile, $sContent, $aNewItems
    $hFile = FileOpen($sDBFile, 0)
    If $hFile <> -1 Then
    $sContent = FileRead($hFile)
    FileClose($hFile)
    $sContent = StringTrimRight($sContent, 2)
    $aNewItems = StringSplit($sContent, @CRLF, 1)
    If Not IsArray($aNewItems) Then Return
    _GUICtrlListView_BeginUpdate($Liste1)
    For $i = 1 To $aNewItems[0]
    GUICtrlCreateListViewItem($aNewItems[$i], $Liste1)
    Next
    _GUICtrlListView_EndUpdate($Liste1)
    EndIf
    EndFunc

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

    Func Save()
    Local $sItem, $hFile, $iCount
    $iCount = _GUICtrlListView_GetItemCount($hLVHandle) - 1
    If $iCount = -1 Then Return FileDelete($sDBFile)
    $hFile = FileOpen($sDBFile, 2)
    If $hFile <> -1 Then
    For $i = 0 To $iCount
    $sItem = _GUICtrlListView_GetItemTextString($hLVHandle, $i)
    FileWriteLine($hFile, $sItem)
    Next
    FileClose($hFile)
    EndIf
    EndFunc

    [/autoit]

    Einmal editiert, zuletzt von Croco1984 (18. Januar 2013 um 16:42)