meteor0330 发表于 2014-8-8 15:18:40

【已解决】怎样将listview中的数据读取后直接存到二维数组中呢?

本帖最后由 meteor0330 于 2014-8-12 08:58 编辑

有如下代码,我想将listview中的数据读取后直接存到二维数组中,能做到吗?


#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 531, 395, 1092, 129)
$ListView1 = GUICtrlCreateListView("row|row1|row2|row3", 30, 20, 456, 326)
$ListView1_0 = GUICtrlCreateListViewItem("a|a1|a2|a3", $ListView1)
$ListView1_1 = GUICtrlCreateListViewItem("b|b1|b2|b3", $ListView1)
$ListView1_2 = GUICtrlCreateListViewItem("c|c1|c2|c3", $ListView1)
$ListView1_3 = GUICtrlCreateListViewItem("d|a1|d2|d3", $ListView1)
$ListView1_4 = GUICtrlCreateListViewItem("e|e1|e2|e3", $ListView1)
$Button1 = GUICtrlCreateButton("存入数组", 70, 355, 65, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        GetItem()
        EndSwitch
WEnd

Func GetItem()
EndFunc   ;==>GetItem

我这个GetItem应该怎么写呢?

tubaba 发表于 2014-8-8 16:34:43

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiListView.au3>
#Include <array.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 531, 395, 1092, 129)
$ListView1 = GUICtrlCreateListView("row|row1|row2|row3", 30, 20, 456, 326)
$ListView1_0 = GUICtrlCreateListViewItem("a|a1|a2|a3", $ListView1)
$ListView1_1 = GUICtrlCreateListViewItem("b|b1|b2|b3", $ListView1)
$ListView1_2 = GUICtrlCreateListViewItem("c|c1|c2|c3", $ListView1)
$ListView1_3 = GUICtrlCreateListViewItem("d|a1|d2|d3", $ListView1)
$ListView1_4 = GUICtrlCreateListViewItem("e|e1|e2|e3", $ListView1)
$Button1 = GUICtrlCreateButton("存入数组", 70, 355, 65, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
      $nMsg = GUIGetMsg()
      Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        GetItem()
      EndSwitch
WEnd

Func GetItem()
        Local $aArray
                For $i = 0 To _GUICtrlListView_GetItemCount($ListView1)-1
                Local $aItem = _GUICtrlListView_GetItemTextArray($ListView1,$i)
                For $j = 1 To UBound($aItem)-1
                        $aArray[$i][$j-1] = $aItem[$j]
                Next
        Next
_ArrayDisplay($aArray)
EndFunc   ;==>GetItem回复 1# meteor0330

meteor0330 发表于 2014-8-8 17:50:24

回复 2# tubaba


    太感谢了!
二维数组把我弄得有点晕了!!

meteor0330 发表于 2014-8-8 18:04:51

更正一下,第32行应该加上StringSplit

zxhou1 发表于 2014-8-11 09:36:15

学习一下。。。谢谢

ak47gglllk 发表于 2014-11-18 10:28:11

数组搞得头疼,感谢,感谢。学习了。非常感谢
页: [1]
查看完整版本: 【已解决】怎样将listview中的数据读取后直接存到二维数组中呢?