找回密码
 加入
搜索
查看: 3360|回复: 4

[GUI管理] listview中如果实现查找搜索并选中功能[已解决]

[复制链接]
发表于 2010-6-26 13:20:46 | 显示全部楼层 |阅读模式
本帖最后由 410521a 于 2010-6-26 16:04 编辑

listview中如果实现查找搜索并选中功能

评分

参与人数 1金钱 +10 收起 理由
afan + 10 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

发表于 2010-6-26 14:04:01 | 显示全部楼层
#include <GUIConstants.au3>
#include <ListviewConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$form1 = GUICreate("listview 项目",220,250, 100,200)
GUISetState (@SW_SHOW)
$listview = GUICtrlCreateListView ("col1",10,10,200,150)
$item1=GUICtrlCreateListViewItem("item1",$listview)
$item2=GUICtrlCreateListViewItem("item2",$listview)
$item3=GUICtrlCreateListViewItem("item3",$listview)


$a = ControlListView($form1, "", $listview, "FindItem", "item3")
ControlListView($form1, "", $listview, "Select", $a)

msgbox(0,"","字符串位置,第:" & $a & "行,已经选中!")

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd
发表于 2010-6-26 14:34:43 | 显示全部楼层
不知道楼上的朋友是不是理解错了,我是这样理解的。
#include <GUIListView.au3>
#include <WindowsConstants.au3>

GUICreate("ListView", 280, 300)
$ListView1 = GUICtrlCreateListView("编号|姓名|ID", 1, 1, 278, 230, -1, _
                BitOR($WS_EX_CLIENTEDGE, $LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT, $LVS_REPORT))
_GUICtrlListView_SetColumnWidth($ListView1, 1, 100)
_GUICtrlListView_SetColumnWidth($ListView1, 2, 100)
$Input1 = GUICtrlCreateInput("李四", 58, 252, 121, 21)
$Button1 = GUICtrlCreateButton("按姓名搜索", 180, 250, 80, 25)

GUICtrlCreateListViewItem('1|张三|65786315', $ListView1)
GUICtrlCreateListViewItem('2|李四|56454688', $ListView1)
GUICtrlCreateListViewItem('3|王五|86575765', $ListView1)
GUICtrlCreateListViewItem('4|孙六|87654832', $ListView1)
GUICtrlCreateListViewItem('5|赵七|96325478', $ListView1)
GUICtrlCreateListViewItem('6|成八|64651873', $ListView1)
GUICtrlCreateListViewItem('7|冯九|96437251', $ListView1)
GUICtrlCreateListViewItem('8|钱十|64976835', $ListView1)
GUISetState()

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case - 3
                        Exit
                Case $Button1
                        _Search(GUICtrlRead($Input1))
        EndSwitch
WEnd

Func _Search($sText)
        $iIndex = _GUICtrlListView_FindInText($ListView1, $sText)
        _GUICtrlListView_ClickItem($ListView1, $iIndex)
EndFunc   ;==>_Search

评分

参与人数 1金钱 +50 收起 理由
hzxymkb + 50 强大

查看全部评分

 楼主| 发表于 2010-6-26 14:46:48 | 显示全部楼层
多谢水木子`` 研究下`
 楼主| 发表于 2010-6-29 11:20:15 | 显示全部楼层
可不可以加个下一个查找?
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-11 08:38 , Processed in 0.079513 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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