Sign in to follow this  
Followers 0
spiderblues

read item in listview and sort

1 post in this topic

Hi,

I already asked in the scripts forum, because I'm using the listview sort of lazycoder: http://www.autoitscript.com/forum/index.php?showtopic=7053

My Problem is, that I'm not able to read the selected item of a listview by mouseclick when I'm using the sort function, because it's using the mouse event for itself...

What am I doing wrong???

Thanks for any help...

spider

#include <GUIConstants.au3>
#include "ArrayLC.au3"
#include "ListViewUDFs.au3"

$LVM_DELETEITEM = 0x1008

Dim $filename = @ScriptDir & "\products.csv"
Dim $pgm_name = "Products"

If $CmdLine[0] > 0 Then $filename = $CmdLine[1]

$GUI = GUICreate($pgm_name,1000, 700, -1, -1,$WS_THICKFRAME + $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
Global $listview = GUICtrlCreateListView ("Product|Description|ItemNr.|Type|Date",10,40,600,500)
Global $inp_lv_1 = GuiCtrlCreateInput("", 10, 10, 80, 20); Edit
Global $inp_lv_2 = GuiCtrlCreateInput("", 100, 10, 80, 20); Edit
Global $inp_lv_3 = GuiCtrlCreateInput("", 190, 10, 80, 20); Edit
Global $inp_lv_4 = GuiCtrlCreateInput("", 280, 10, 80, 20); Edit
Global $inp_lv_5 = GuiCtrlCreateInput("", 370, 10, 80, 20); Edit

$btn_edit = GuiCtrlCreateButton ("Edit",10,550,70,20)

$file = FileOpen($filename, 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open specified search results file...")
    Exit
EndIf
; Read in lines of text until the EOF is reached
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    GUICtrlCreateListViewItem(StringReplace($line,@TAB,"|"),$listview)
Wend
FileClose($file)

GUISetState()

Dim $b_Descending[_GUICtrlGetListViewColsCount($listview)]

Do
    $msg = GUIGetMsg ()
    Select
        Case $msg = $listview
        _SortListView($listview,$b_Descending,GuiCtrlGetState($listview))

        Case $msg = $btn_edit
        $strSelFile = StringSplit(GUICtrlRead(GUICtrlRead($listview)),"|")
        If $strSelFile[0] > 1 Then
            GUICtrlSetData ($inp_lv_1, $strSelFile[1])
            GUICtrlSetData ($inp_lv_2, $strSelFile[2])
            GUICtrlSetData ($inp_lv_3, $strSelFile[3])
            GUICtrlSetData ($inp_lv_4, $strSelFile[4])
            GUICtrlSetData ($inp_lv_5, $strSelFile[5])
        Else
            MsgBox(0, "Error", "Please select line to edit!")
        EndIf
    EndSelect
Until $msg = $GUI_EVENT_CLOSE

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0