Sign in to follow this  
Followers 0
ptrex

Read data from a ListView without selecting ?

5 posts in this topic

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

you mean something like?

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_Get, $Btn_Exit, $msg, $Status, $ret
GUICreate("ListView Get Item Text", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
$Btn_Get = GUICtrlCreateButton("Get data", 75, 200, 90, 40)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Status = GUICtrlCreateLabel("", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
            ExitLoop
        Case $msg = $Btn_Get
            GUICtrlSetData($Status, "")
            Local $a_list, $x
            For $x = 0 To _GUICtrlListViewGetItemCount($listview) - 1
                If IsArray($a_list) Then
                    ReDim $a_list[UBound($a_list) + 1]
                Else
                    Dim $a_list[1]
                EndIf
                $a_list[UBound($a_list) - 1] = _GUICtrlListViewGetItemText ($listview, $x)
            Next
            For $x = 0 To UBound($a_list) - 1
                MsgBox(0,"a_list[" & $x & "]",$a_list[$x])
            Next
    EndSelect
WEnd
Exit
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Hihaaaaa, that' s it !!

This is a good suggestion for a standard UDF.

Because I thought that the functions like _GUICtrlListViewGetItemText would read all or part, of the data from the ListView. As it is said in the Helpfile text

Found out later on that it only read the data, after manually selecting it.

So you solution is missing as a standard function. Maybe usefull for many others.

May come handy when people working with listView, want to read the data for what ever reason, and use it later on.

I will incorporate your solution in the SQL solution, for exporting data from a ListView to a file or Excel.

Thanks a lot !!

Share this post


Link to post
Share on other sites

@ptrex

Because I thought that the functions like _GUICtrlListViewGetItemText would read all or part, of the data from the ListView. As it is said in the Helpfile text

Found out later on that it only read the data, after manually selecting it

You were right on the first part. _GUICtrlListViewGetItemText() dosen't need any ListView items to be selected. The script by gafrost is not selecting any ListView items.

The second part is not correct.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

now that i had some coffee and am awake, didn't need as many lines of code to get the data

Local $a_list[_GUICtrlListViewGetItemCount($listview)], $x
            For $x = 0 To _GUICtrlListViewGetItemCount($listview) - 1
                $a_list[$x] = _GUICtrlListViewGetItemText ($listview, $x)
            Next
            For $x = 0 To UBound($a_list) - 1
                MsgBox(0,"a_list[" & $x & "]",$a_list[$x])
            Next
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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