410521a 发表于 2010-6-26 13:20:46

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

本帖最后由 410521a 于 2010-6-26 16:04 编辑

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

xsjtxy 发表于 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

410521a 发表于 2010-6-26 14:46:48

多谢水木子`` 研究下`

410521a 发表于 2010-6-29 11:20:15

可不可以加个下一个查找?
页: [1]
查看完整版本: listview中如果实现查找搜索并选中功能[已解决]