关于GUICtrlCreateListviewItem数值的计算
RT,下图中数值2的内容该如何去取其值并合计表格内的总和?#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <GuiListview.au3>
#Region ### START Koda GUI section ### Form=
Local $iExListviewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, $LVS_EX_DOUBLEBUFFER)
$Form1 = GUICreate("Form1", 634, 454, 192, 114)
$List1 = GuiCtrlCreateListview("数值1|数值2|数值3", 0, 0, 633, 331)
_GuiCtrlListview_SetColumnWidth($List1, 0,450)
GUICtrlSendMsg($List1, $LVM_SETEXTENDEDListviewSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
$item1 = GUICtrlCreateListviewItem("数据内容1|954544878784545|1", $List1)
$item2 = GUICtrlCreateListviewItem("数据内容2|56468487984848948|2", $List1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Form1
Case $List1
EndSwitch
WEnd
[ 本帖最后由 ceoguang 于 2009-1-31 16:23 编辑 ] #include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <GuiListview.au3>
#Region ### START Koda GUI section ### Form=
Local $iExListviewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, $LVS_EX_DOUBLEBUFFER)
$Form1 = GUICreate("Form1", 634, 454, 192, 114)
$List1 = GuiCtrlCreateListview("数值1|数值2|数值3", 0, 0, 633, 331)
_GuiCtrlListview_SetColumnWidth($List1, 0,450)
GUICtrlSendMsg($List1, $LVM_SETEXTENDEDListviewSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
$item1 = GUICtrlCreateListviewItem("数据内容1|954544|1", $List1)
$item2 = GUICtrlCreateListviewItem("数据内容2|56468487|2", $List1)
;$item3=GUICtrlCreateListviewItem("合计|"&Number(GUICtrlRead($item1))+Number(GUICtrlRead($item2))&"|bbb")
;MsgBox(0,0,GUICtrlRead($item1))
$hj1=GUICtrlCreateInput("",400,350,100,20)
$hj2=GUICtrlCreateInput("",520,350,100,20)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$S1=StringSplit(GUICtrlRead($item1),"|")
$s2=StringSplit(GUICtrlRead($item2),"|")
$H1=$S1+$S2
$H2=$S1+$S2
GUICtrlSetData($hj1,$H1)
GUICtrlSetData($hj2,$H2)
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Form1
Case $List1
EndSwitch
WEnd
替换是可以去除的$ver = _GUICtrlListView_GetItemTextArray($List1, $n)
$ver的值就是数值2的内容了,但怎么样才能循环相加呢? 大叔再进来下,如果有N个item的话怎么去循环相加? 用for循环吧。简单明了 呵呵,偏偏我就是被这个for难住了 #include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <GuiListview.au3>
#Region ### START Koda GUI section ### Form=
Local $iExListviewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, $LVS_EX_DOUBLEBUFFER)
$Form1 = GUICreate("Form1", 634, 454, 192, 114)
$List1 = GuiCtrlCreateListview("数值1|数值2|数值3", 0, 0, 633, 331)
_GuiCtrlListview_SetColumnWidth($List1, 0,450)
GUICtrlSendMsg($List1, $LVM_SETEXTENDEDListviewSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
$item1 = GUICtrlCreateListviewItem("数据内容1|100|1", $List1)
$item2 = GUICtrlCreateListviewItem("数据内容2|100|2", $List1)
$item3 = GUICtrlCreateListviewItem("数据内容2|100|3", $List1)
$item4 = GUICtrlCreateListviewItem("数据内容2|100|4", $List1)
$item5 = GUICtrlCreateListviewItem("数据内容2|100|5", $List1)
$item6 = GUICtrlCreateListviewItem("数据内容2|100|6", $List1)
$hj1=GUICtrlCreateInput("",400,350,100,20)
$hj2=GUICtrlCreateInput("",520,350,100,20)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$cont=_GUICtrlListView_GetItemCount ($List1)
$h1=0
$h2=0
for $i=0 to $cont-1
$S=_GUICtrlListView_GetItemTextArray($List1, $i)
$h1=$h1+$S
$h2=$h2+$S
Next
GUICtrlSetData($hj1,$H1)
GUICtrlSetData($hj2,$H2)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Form1
Case $List1
EndSwitch
WEnd
[ 本帖最后由 顽固不化 于 2009-1-31 16:22 编辑 ] 原来要-1。受教了,谢谢 原帖由 ceoguang 于 2009-1-31 15:56 发表 http://www.autoitx.com/images/common/back.gif
大叔再进来下,如果有N个item的话怎么去循环相加?
顽固不化是大叔?是30几还是40几啊 原帖由 ken0137 于 2009-1-31 20:39 发表 http://www.autoitx.com/images/common/back.gif
顽固不化是大叔?是30几还是40几啊
哈哈,这是秘密!!! 如何实现排序呢/? 非常有用,感谢分享!
页:
[1]