找回密码
 加入
搜索
查看: 4258|回复: 7

[效率算法] 请教ListView的问题,在ListView上单击后便显示被选择的数量

  [复制链接]
发表于 2010-12-16 12:57:15 | 显示全部楼层 |阅读模式
本帖最后由 zz999 于 2010-12-16 13:04 编辑

代码贴上
我想实现每选中一项就显示被选择的数量,
放在WHILE里 ,虽然实现了但一直在刷新。
请教有什么办法不?
另外MSGBOX被选中的序号相加值      不知道如何弄!
请大家帮忙!
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("窗体1", 405, 294, 302, 218)
$ListView1 = GUICtrlCreateListView("编号|名称", 16, 16, 369, 201)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 235)
_GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_CHECKBOXES))
$LABEL1 = GUICTRLCREATELABEL("2222222", 142, 248, 113, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Write()
While 1
        $nMsg = GUIGetMsg()
                RdListView()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd
Func Write()
        For $i = 1 To 10
                GUICtrlCreateListViewItem($i & '|KB' & $i, $ListView1)
        Next
EndFunc   ;==>Write


Func RdListView()
        $s = 0
        $log = _GUICtrlListView_GetItemCount($ListView1)
        For $i = 0 To $log
                If _GUICtrlListView_GetItemChecked($ListView1, $i) = True Then
                        $s += 1
                EndIf
                        Next
                        GUICtrlSetData($LABEL1,$log&"个中的"&$S&"个被选择")
EndFunc   ;==>RdListView
 楼主| 发表于 2010-12-16 15:59:08 | 显示全部楼层
来人 帮帮忙喔!
发表于 2010-12-16 16:16:17 | 显示全部楼层
本帖最后由 yhxhappy 于 2010-12-16 16:17 编辑
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <Array.au3>

$Form1 = GUICreate("窗体1", 405, 294, 302, 218)
$ListView1 = GUICtrlCreateListView("编号|名称", 16, 16, 369, 201)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 235)
_GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_CHECKBOXES))
$LABEL1 = GUICTRLCREATELABEL("", 142, 248, 113, 33)

GUISetState(@SW_SHOW)

Local $Item[1]                ;创建一个数组存放 ListViewItem 的控件ID

Write()

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Item[1] To $Item[$Item[0]]
                        $s = 0
                        $log = _GUICtrlListView_GetItemCount($ListView1)
                        For $i = 0 To $log
                                If _GUICtrlListView_GetItemChecked($ListView1, $i) = True Then
                                        $s += 1
                                EndIf
                        Next
                        GUICtrlSetData($LABEL1,$log&"个中的"&$S&"个被选择")                                                
        EndSwitch
WEnd
        
Func Write()
        For $i = 1 To 10
                        ReDim $Item[UBound($Item)+1]
                        $Item[UBound($Item)-1] = GUICtrlCreateListViewItem($i & '|KB' & $i, $ListView1)
        Next
                $Item[0] = UBound($Item)-1
EndFunc   ;==>Write

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

 楼主| 发表于 2010-12-16 16:48:19 | 显示全部楼层
回复 3# yhxhappy

谢谢你的回答,但是没+ne0 解决问题

如果GUICtrlCreateListViewItem的数据是读取的INI里的呢?
 楼主| 发表于 2010-12-16 17:40:04 | 显示全部楼层
我用WM_NOTIFY        但是WM_NOTIFY是单击后显示的是单击前的状态!
发表于 2010-12-16 17:49:20 | 显示全部楼层
回复 4# zz999


    那你得把INI文件补上才能改啊
 楼主| 发表于 2010-12-16 19:52:27 | 显示全部楼层
回复 6# yhxhappy


    可否留个Q  请教下!
发表于 2010-12-17 08:12:40 | 显示全部楼层
路过学习学习....
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-4 03:41 , Processed in 0.082409 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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