找回密码
 加入
搜索
查看: 4906|回复: 11

[GUI管理] [已解决]ListView如何进行列计算

  [复制链接]
发表于 2014-7-1 16:23:25 | 显示全部楼层 |阅读模式
本帖最后由 jianganew 于 2014-7-3 08:34 编辑

请问ListView如何进行列计算?

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>

$Debug_LV = False

_Main()

Func _Main()
    Local $aItem, $sText, $hListView

    GUICreate("列计算", 400, 300)

    $hListView = GUICtrlCreateListView("col1|col2|col3|col4|col5", 2, 2, 394, 268)
    GUICtrlCreateListViewItem("line1|1|2|3|4", $hListView)
    GUICtrlCreateListViewItem("line2|2|3|4|5", $hListView)
    GUICtrlCreateListViewItem("line3|3|4|5|6", $hListView)
    GUICtrlCreateListViewItem("line4|4|5|6|7", $hListView)
    GUICtrlCreateListViewItem("line5|5|6|7|8", $hListView)
    GUICtrlCreateListViewItem("line6|6|7|8|9", $hListView)
    GUICtrlCreateListViewItem("line7|7|8|9|10", $hListView)
    GUICtrlCreateListViewItem("line8|8|9|10|11", $hListView)
    GUISetState()
       
$hang=_GUICtrlListView_GetItemCount($hListview)
$lie=_GUICtrlListView_GetColumnCount($hListview)
Local $aArray
For $i=0 to $hang-1 Step 1
$aArray=_GUICtrlListView_GetItemText($hListview,$i,3)
$ZXA=$aArray
MsgBox(4096,"测试","结果: " & @CRLF & $ZXA)
Next

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2014-7-1 20:41:29 | 显示全部楼层
读入二维数组然后计算不就行了
 楼主| 发表于 2014-7-2 09:43:48 | 显示全部楼层
还是不懂,请高手给写个代码,谢谢了。
 楼主| 发表于 2014-7-2 09:44:09 | 显示全部楼层
还是不懂,请高手给写个代码,谢谢了。
发表于 2014-7-2 12:18:16 | 显示全部楼层
等待高手给你解读
发表于 2014-7-2 14:34:56 | 显示全部楼层
$hListView  本身是無法 做運算的  只能用  FOR   NEXT  一筆一筆的資料讀取出來 做加總
 楼主| 发表于 2014-7-2 14:57:20 | 显示全部楼层
读取之后如何建立数组?如何数组求和?
还请各位多多指点,先谢了。
发表于 2014-7-2 15:04:26 | 显示全部楼层
回复 7# jianganew

可以先找到數組的範例嗎??  數組 怎麼 秀出每一個的值呢???  知道了怎麼秀出每一個的值  不就知道怎麼加總了嗎??
发表于 2014-7-2 15:39:44 | 显示全部楼层
回复 7# jianganew

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>

$Debug_LV = False 

_Main()

Func _Main()
    Local $aItem, $sText, $hListView

    GUICreate("列計算", 400, 300)

    $hListView = GUICtrlCreateListView("col1|col2|col3|col4|col5", 2, 2, 394, 268)
    GUICtrlCreateListViewItem("line1|1|2|3|4", $hListView)
    GUICtrlCreateListViewItem("line2|2|3|4|5", $hListView)
    GUICtrlCreateListViewItem("line3|3|4|5|6", $hListView)
    GUICtrlCreateListViewItem("line4|4|5|6|7", $hListView)
    GUICtrlCreateListViewItem("line5|5|6|7|8", $hListView)
    GUICtrlCreateListViewItem("line6|6|7|8|9", $hListView)
    GUICtrlCreateListViewItem("line7|7|8|9|10", $hListView)
    GUICtrlCreateListViewItem("line8|8|9|10|11", $hListView)
    GUISetState()
        
$hang=_GUICtrlListView_GetItemCount($hListview)
$lie=_GUICtrlListView_GetColumnCount($hListview)
Local $aArray

FOR $j=1 TO 3
                $TOTAL=0
                For $i=0 to $hang-1 Step 1
                $aArray=_GUICtrlListView_GetItemText($hListview,$i,$j)
                
                $TOTAL=$TOTAL+$aArray
                Next
        MsgBox(4096,"測試","第 "&$j&" 欄的總合為: " &$TOTAL)
Next
        
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main

评分

参与人数 1金钱 +10 收起 理由
jianganew + 10 谢谢帮忙

查看全部评分

 楼主| 发表于 2014-7-2 16:49:20 | 显示全部楼层
多谢kk_lee69 。
发表于 2014-7-2 17:55:32 | 显示全部楼层
回复 10# jianganew

問題解決了  請記得在標題 加上 已解決
发表于 2014-7-3 13:44:17 | 显示全部楼层
感谢,感谢,感谢,感谢,感谢
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-18 12:41 , Processed in 0.103668 second(s), 29 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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