找回密码
 加入
搜索
查看: 8969|回复: 5

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

[复制链接]
发表于 2014-8-8 15:18:40 | 显示全部楼层 |阅读模式
本帖最后由 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应该怎么写呢?
发表于 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[_GUICtrlListView_GetItemCount($ListView1)][_GUICtrlListView_GetColumnCount($ListView1)]
                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
 楼主| 发表于 2014-8-8 17:50:24 | 显示全部楼层
回复 2# tubaba


    太感谢了!
二维数组把我弄得有点晕了!!
 楼主| 发表于 2014-8-8 18:04:51 | 显示全部楼层
更正一下,第32行应该加上StringSplit
发表于 2014-8-11 09:36:15 | 显示全部楼层
学习一下。。。谢谢
发表于 2014-11-18 10:28:11 | 显示全部楼层
数组搞得头疼,感谢,感谢。学习了。非常感谢
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-18 12:12 , Processed in 0.078860 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表