Sign in to follow this  
Followers 0
ajit

Array from Listviewitems

7 posts in this topic

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <Array.au3>


    Global $hListView, $msg, $Array_Display_Button

    GUICreate("ListView Test", 400, 300)
    $hListView = GUICtrlCreateListView("col1|col2|col3", 2, 2, 394, 258)
    GUISetState()

    GUICtrlCreateListViewItem("line1|data1|more1", $hListView)
    GUICtrlCreateListViewItem("line2|data2|more2", $hListView)
    GUICtrlCreateListViewItem("line3|data3|more3", $hListView)
    GUICtrlCreateListViewItem("line4|data4|more4", $hListView)
    GUICtrlCreateListViewItem("line5|data5|more5", $hListView)

    $Array_Display_Button = Guictrlcreatebutton("Array Display", 280, 265, 100, 25)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Array_Display_Button
            ;_guictrllistview_Getitemcount($hListView)
            ;_GUICtrlListView_GetItemTextArray($hListView)
            ;_ArrayDisplay()

    Endselect
Wend

Hi:

I have a listview with three columns and some rows. I want to obtain an array of all the items in the listview.

Could someone help me with this.

Thanking in anticipation.

Regards

Ajit

Share this post


Link to post
Share on other sites



ajit,

You can do it like this: :x

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <Array.au3>

Global $hListView, $msg, $Array_Display_Button

GUICreate("ListView Test", 400, 300)
$hListView = GUICtrlCreateListView("col1|col2|col3", 2, 2, 394, 258)
GUISetState()

$hLV_Start = GUICtrlCreateDummy() + 1

GUICtrlCreateListViewItem("line1|data1|more1", $hListView)
GUICtrlCreateListViewItem("line2|data2|more2", $hListView)
GUICtrlCreateListViewItem("line3|data3|more3", $hListView)
GUICtrlCreateListViewItem("line4|data4|more4", $hListView)
GUICtrlCreateListViewItem("line5|data5|more5", $hListView)

$hLV_End = GUICtrlCreateDummy()

$Array_Display_Button = Guictrlcreatebutton("Array Display", 280, 265, 100, 25)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Array_Display_Button

            $iCount = $hLV_End - $hLV_Start
            Global $aArray[$iCount]
            For $i = 0 To $iCount - 1
                $aArray[$i] = GUICtrlRead($hLV_Start + $i)
            Next
            _ArrayDisplay($aArray)
    Endselect
Wend

I will leave it to you to split the lines into separate columns! :P

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

@Melba:

Thanks very much for your quick reply.

Now I am able to get an array but still lost as to how to seperate and put them in seperate columns. Please could you give me a clue how to go about it.

Thanks again

Regards

Ajit

Edited by ajit

Share this post


Link to post
Share on other sites

ajit,

Look at StringSplit in the Help file and see if it makes any lightbulbs go off! :x

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

@Melba:

Really feeling ashamed to admit I do not know how (or where) to use it in this context.

Regards

Ajit

Share this post


Link to post
Share on other sites

ajit,

do not know how (or where) to use it

Sigh..........that is what the Help file is for! :P

But as I am feeling generous today: :shifty:

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <Array.au3>

GUICreate("ListView Test", 400, 300)
$hListView = GUICtrlCreateListView("col1|col2|col3", 2, 2, 394, 258)
GUISetState()

$hLV_Start = GUICtrlCreateDummy() + 1

GUICtrlCreateListViewItem("line1|data1|more1", $hListView)
GUICtrlCreateListViewItem("line2|data2|more2", $hListView)
GUICtrlCreateListViewItem("line3|data3|more3", $hListView)
GUICtrlCreateListViewItem("line4|data4|more4", $hListView)
GUICtrlCreateListViewItem("line5|data5|more5", $hListView)

$Array_Display_Button = Guictrlcreatebutton("Array Display", 280, 265, 100, 25)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Array_Display_Button
            ; Get size of LV
            $iItemCount = _GUICtrlListView_GetItemCount($hListView)
            $iColCount = _GUICtrlListView_GetColumnCount($hListView)
            ; Create correctly sized array
            Global $aArray[$iItemCount][$iColCount]
            ; For each line
            For $i = 0 To $iItemCount - 1
                ; Get full text
                $sFullText = GUICtrlRead($hLV_Start + $i)
                ; Split the line into the column elements
                $aColText = StringSplit($sFullText, "|")
                ; Add the elements to the array
                For $j = 1 To $iColCount
                    $aArray[$i][$j - 1] = $aColText[$j]
                Next
            Next
            ; Display the array
            _ArrayDisplay($aArray)
    Endselect
Wend

More effort required from you next time! :x

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

@M23:

Thanks a lot. I wouldn’t have been able to figure that out without your help.

Thanks again

Ajit

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