找回密码
 加入
搜索
查看: 11369|回复: 37

[AU3基础] 如何设置ListView指定列数据输出到Combox供选择??

 火.. [复制链接]
发表于 2012-9-26 22:34:25 | 显示全部楼层 |阅读模式
本帖最后由 邪恶海盗 于 2012-9-26 22:36 编辑

如题,比如现在有一个ListView:
11-22|333|333|333
11-21|434|332|222
12-21|89|94|33|33

如何提取出首列数据并以"-"分开写入至Combox1和Combox2以供选择???

附带要求:当Combox1选中11时,Combox2内只出现22和21以供选择,或许可以简单一点,先只写Combox1,当Combox1选择数据之后再写Combox2...


请高淫指导...
 楼主| 发表于 2012-9-27 19:37:36 | 显示全部楼层
高淫都哪去了???
发表于 2012-9-27 20:35:52 | 显示全部楼层
回复 2# 邪恶海盗


    不是不想帮你,只是帮助里都能找到解决办法的,为什么都想着伸手就拿?
发表于 2012-9-27 20:43:45 | 显示全部楼层

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>

#include <ComboConstants.au3>
#include <GuiListView.au3>

Global $ListView1_[10]
Global $a[10]
Global $b[10]
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 449, 192, 114)
$ListView1 = GUICtrlCreateListView("1|2|3|4|5", 16, 24, 250, 200)
$ListView1_[0] = GUICtrlCreateListViewItem("11-22|333|333|333", $ListView1)
_GUICtrlListView_SetColumnWidth($ListView1, 0, 100)
$ListView1_[1] = GUICtrlCreateListViewItem("11-21|434|332|222", $ListView1)
$ListView1_[2] = GUICtrlCreateListViewItem("12-21|89|94|33|33", $ListView1)

$Combo1 = GUICtrlCreateCombo("", 350, 24, 100, 25, $CBS_DROPDOWNLIST)
$Combo2 = GUICtrlCreateCombo("", 480, 24, 100, 25, $CBS_DROPDOWNLIST)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Local $i
Local $j
Local $array_all_line
Local $array_head
Local $str1
Local $str2
For $i = 0 To 2
        $array_all_line = StringSplit(GUICtrlRead($ListView1_[$i]), "|")
        $array_head = StringSplit($array_all_line[1], "-")
        $a[$i] = $array_head[1]
        $b[$i] = $array_head[2]
Next

$str1 = $a[0]
For $i = 1 To 2
        For $j = 0 To $i-1
                If $a[$i]=$a[$j] Then
                        ExitLoop
                EndIf
        Next
        If $j = $i Then $str1 &= "|" & $a[$i]
Next
GUICtrlSetData($Combo1, $str1)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Combo1
                        Local $combo_item = GUICtrlRead($Combo1)
                        GUICtrlSetData($Combo2, "")
                        $str2 = ""
                        For $i = 0 To 2
                                If $a[$i] = $combo_item Then
                                        If $str2 = "" Then
                                                $str2 &= $b[$i]
                                        Else
                                                $str2 &=  "|" & $b[$i]
                                        EndIf
                                EndIf
                        Next
                        GUICtrlSetData($Combo2, $str2)
        EndSwitch
WEnd
发表于 2012-9-27 20:50:14 | 显示全部楼层
效果图
[img][/img]

本帖子中包含更多资源

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

×
 楼主| 发表于 2012-9-27 21:01:15 | 显示全部楼层
回复 3# 半芯竹


    还真不知道哪有,没找到...
 楼主| 发表于 2012-9-27 21:06:17 | 显示全部楼层
回复 5# veket_linux


    3Q,没天试试...
 楼主| 发表于 2012-9-28 12:25:00 | 显示全部楼层
回复 5# veket_linux


    如果ListView数据是从数据库读取后显示出来的,要怎么整???
 楼主| 发表于 2012-9-28 20:52:25 | 显示全部楼层
For $six =0 To XXX
                GUICtrlSetData($combo23,_GUICtrlListView_GetItemText($list3, $six,0))
Next

这样就可以输出首列数据了,不过XXX的数量,也就是ListView第一列数据的总行数怎么确定???
 楼主| 发表于 2012-9-28 21:03:06 | 显示全部楼层
本帖最后由 邪恶海盗 于 2012-9-28 21:07 编辑

用_GUICtrlListView_GetItemCount($List3)-2搞定了,但不知道原理...

                GUICtrlSetData($combo23,StringLeft(_GUICtrlListView_GetItemText($list3, $six),3))
用于提取首列数据前三个字符至Combo23,然后另外一个怎么识别不会了...
 楼主| 发表于 2012-9-30 13:00:00 | 显示全部楼层
For $six =0 To _GUICtrlListView_GetItemCount($List3)-1;获取有数据的行数
        $cci=StringSplit(_GUICtrlListView_GetItemText($list3, $six),"-");提取每行首列数据并分拆字符
                GUICtrlSetData($combo23,$cci[1]);将获取到的数据写入combo24
Next

Case $combo23

        $iI = _GUICtrlListView_FindInText($list3, GUICtrlRead($combo23));搜索combo23所在行
        $mpbz=StringSplit (_GUICtrlListView_GetItemText($list3,$iI),"-");提取指定行首列数据并分拆字符
GUICtrlSetData($combo24,$mpbz[2]);输出获取到的数据到combo24


Combo23数据获取正常,
当Combo23选择后,Combo24只显示一个标记,其它不显示,
Combo23再次选择时,Combo24将添加一个标记,原标记还在下拉菜单内,不符合我要求的效果,求高手指导...
 楼主| 发表于 2012-10-4 10:00:41 | 显示全部楼层
高淫们国庆都把妹去了么???
发表于 2012-10-4 10:03:50 | 显示全部楼层
学习,学习。。。。。。。。。
发表于 2012-10-4 10:36:09 | 显示全部楼层
学习学习
发表于 2012-10-6 17:27:23 | 显示全部楼层
_GUICtrlListView_GetItemTextArray
更好点吧,可以指定列索引,不用拆
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-20 06:03 , Processed in 0.086186 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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