ajit Posted December 10, 2010 Share Posted December 10, 2010 #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 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 10, 2010 Moderators Share Posted December 10, 2010 ajit, You can do it like this: expandcollapse popup#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! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ajit Posted December 10, 2010 Author Share Posted December 10, 2010 (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 December 10, 2010 by ajit Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 10, 2010 Moderators Share Posted December 10, 2010 ajit,Look at StringSplit in the Help file and see if it makes any lightbulbs go off! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ajit Posted December 10, 2010 Author Share Posted December 10, 2010 @Melba: Really feeling ashamed to admit I do not know how (or where) to use it in this context. Regards Ajit Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 10, 2010 Moderators Share Posted December 10, 2010 ajit, do not know how (or where) to use itSigh..........that is what the Help file is for! But as I am feeling generous today: expandcollapse popup#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! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ajit Posted December 10, 2010 Author Share Posted December 10, 2010 @M23: Thanks a lot. I wouldn’t have been able to figure that out without your help. Thanks again Ajit Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now