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

[AU3基础] [已解决]求解答部分可被选择ListView项目添加或删除

  [复制链接]
发表于 2013-2-22 19:07:23 | 显示全部楼层 |阅读模式
本帖最后由 gold13 于 2013-2-23 13:27 编辑

请高手帮助一下,如何将ListView1控件中,只要部分检查框(Check)控件添加到ListView2控件中。
我试了多次,就不知道怎么做,难道列表视图项目(ListViewItem)控件没有状态吗?这如何处理,向各位高手求教了。
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
#region ### START Koda GUI section ### Form=
Dim $arr1[15]
$Form1 = GUICreate("Form1", 808, 173, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$ListView1 = GUICtrlCreateListView("杆型|名称|型号|单位|数量", 24, 8, 313, 145, -1,  BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES,$LVS_EX_CHECKBOXES,$LVS_EX_FULLROWSELECT))
$arr1[0]=GUICtrlCreateListViewItem("D,DY1-2|横担|∠63×6×1400|根|2", $ListView1)
$arr1[1]=GUICtrlCreateListViewItem("D,DY1-2|六角螺栓|M16×300|付|4", $ListView1)
$arr1[2]=GUICtrlCreateListViewItem("D,DY1-2|六角螺栓|M16×250|付|4", $ListView1)
$arr1[3]=GUICtrlCreateListViewItem("D,DY1-2|弧形垫座|3#,1#|付|2", $ListView1)
$arr1[4]=GUICtrlCreateListViewItem("D,DY1-2|蝶式绝缘子|ED|只|8", $ListView1)
$arr1[5]=GUICtrlCreateListViewItem("D,DY1-2|六角螺栓|M16×150|付|8", $ListView1)
$arr1[6]=GUICtrlCreateListViewItem("D,DY1-2|垫片|φ17.5|个|28", $ListView1)
$arr1[7]=GUICtrlCreateListViewItem("DKD|横担|∠63×6×1400|根|2", $ListView1)
$arr1[8]=GUICtrlCreateListViewItem("DKD|弧形垫座|3#,1#|付|2", $ListView1)
$arr1[9]=GUICtrlCreateListViewItem("DKD|六角螺栓|M16×300|付|2", $ListView1)
$arr1[10]=GUICtrlCreateListViewItem("DKD|六角螺栓|M16×250|付|2", $ListView1)
$arr1[11]=GUICtrlCreateListViewItem("DKD|断连角铁|∠63×6×504|根|4", $ListView1)
$arr1[12]=GUICtrlCreateListViewItem("DKD|耐张绝缘子串|XP-40C|串|4", $ListView1)
$arr1[13]=GUICtrlCreateListViewItem("DKD|六角螺栓|M16×35|付|8", $ListView1)
$arr1[14]=GUICtrlCreateListViewItem("DKD|垫片|φ17.5|个|28", $ListView1)
For $i=3 To 14
GUICtrlsetState($arr1[$i],$GUI_CHECKED)
Next
$ListView2 = GUICtrlCreateListView("杆型|名称|型号|单位|数量", 479, 8, 313, 145, -1,  BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES,$LVS_EX_CHECKBOXES,$LVS_EX_FULLROWSELECT))
$Button1 = GUICtrlCreateButton("添加", 360, 32, 89, 25)
GUICtrlSetOnEvent(-1, "Button1Click")
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
        Sleep(100)
WEnd
Func Button1Click()
For $i=0 To 14       
If GUICtrlGetState($arr1[$i])=$GUI_CHECKED Then        GUICtrlCreateListViewItem(GUICtrlRead($arr1[$i]), $ListView2)
Next
EndFunc
Func Form1Close()
        Exit
EndFunc   ;==>Form1Close
发表于 2013-2-22 23:55:17 | 显示全部楼层
这个不懂,帮你顶下
发表于 2013-2-23 08:33:39 | 显示全部楼层
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiListView.au3>

Opt("GUIOnEventMode", 1)
#region ### START Koda GUI section ### Form=
Dim $arr1[15]
$Form1 = GUICreate("Form1", 808, 173, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$ListView1 = GUICtrlCreateListView("杆型|名称|型号|单位|数量", 24, 8, 313, 145, -1,  BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES,$LVS_EX_CHECKBOXES,$LVS_EX_FULLROWSELECT))
$arr1[0]=GUICtrlCreateListViewItem("D,DY1-2|横担|∠63×6×1400|根|2", $ListView1)
$arr1[1]=GUICtrlCreateListViewItem("D,DY1-2|六角螺栓|M16×300|付|4", $ListView1)
$arr1[2]=GUICtrlCreateListViewItem("D,DY1-2|六角螺栓|M16×250|付|4", $ListView1)
$arr1[3]=GUICtrlCreateListViewItem("D,DY1-2|弧形垫座|3#,1#|付|2", $ListView1)
$arr1[4]=GUICtrlCreateListViewItem("D,DY1-2|蝶式绝缘子|ED|只|8", $ListView1)
$arr1[5]=GUICtrlCreateListViewItem("D,DY1-2|六角螺栓|M16×150|付|8", $ListView1)
$arr1[6]=GUICtrlCreateListViewItem("D,DY1-2|垫片|φ17.5|个|28", $ListView1)
$arr1[7]=GUICtrlCreateListViewItem("DKD|横担|∠63×6×1400|根|2", $ListView1)
$arr1[8]=GUICtrlCreateListViewItem("DKD|弧形垫座|3#,1#|付|2", $ListView1)
$arr1[9]=GUICtrlCreateListViewItem("DKD|六角螺栓|M16×300|付|2", $ListView1)
$arr1[10]=GUICtrlCreateListViewItem("DKD|六角螺栓|M16×250|付|2", $ListView1)
$arr1[11]=GUICtrlCreateListViewItem("DKD|断连角铁|∠63×6×504|根|4", $ListView1)
$arr1[12]=GUICtrlCreateListViewItem("DKD|耐张绝缘子串|XP-40C|串|4", $ListView1)
$arr1[13]=GUICtrlCreateListViewItem("DKD|六角螺栓|M16×35|付|8", $ListView1)
$arr1[14]=GUICtrlCreateListViewItem("DKD|垫片|φ17.5|个|28", $ListView1)
For $i=3 To 14
GUICtrlsetState($arr1[$i],$GUI_CHECKED)
Next
$ListView2 = GUICtrlCreateListView("杆型|名称|型号|单位|数量", 479, 8, 313, 145, -1,  BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES,$LVS_EX_CHECKBOXES,$LVS_EX_FULLROWSELECT))
$Button1 = GUICtrlCreateButton("添加", 360, 32, 89, 25)
GUICtrlSetOnEvent(-1, "Button1Click")
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
        Sleep(100)
WEnd
Func Button1Click()
For $i=0 To 14  
If _GUICtrlListView_GetItemChecked($ListView1,$i) Then  
GUICtrlCreateListViewItem(GUICtrlRead($arr1[$i]), $ListView2)
endif
Next 
EndFunc
Func Form1Close()
        Exit
EndFunc   ;==>Form1Close
 楼主| 发表于 2013-2-23 13:23:14 | 显示全部楼层
谢谢指导。
发表于 2013-2-25 18:55:27 | 显示全部楼层
感謝分享~~
发表于 2014-3-30 22:20:59 | 显示全部楼层
学习了,谢谢分享。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-11-24 11:21 , Processed in 0.102291 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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