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

关于设置listview item选中问题

[复制链接]
发表于 2009-12-18 10:08:31 | 显示全部楼层 |阅读模式
本帖最后由 Netfox 于 2009-12-18 11:19 编辑

请各位达达先看看下面两幅图片



       图一



    图二

我的代码如下:

Case $Button[6]
                        $text = GUICtrlRead($input1)
                        $y = _GUICtrlListView_FindInText($ListView1, $text)                                               
                        _GUICtrlListView_EnsureVisible($ListView1, $y)
                        _GUICtrlListView_SetItemSelected($ListView1, $y)
                        MsgBox(0,"",_GUICtrlListView_GetItemSelected($ListView1, $y))

用_GUICtrlListView_SetItemSelected($ListView1, $y)已经选中了根据$y = _GUICtrlListView_FindInText($ListView1, $text)得到的item,用_GUICtrlListView_GetItemSelected($ListView1, $y))返回的信息已看到为TURE,我的目的是要像图二那样,选中所要的item,使它呈现出像用鼠标点它一样,有一块背景色。不知我把问题描述清楚没,希望各位帮帮忙。

本帖子中包含更多资源

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

×

评分

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

查看全部评分

发表于 2009-12-18 10:31:16 | 显示全部楼层
_GUICtrlListView_SetItemSelected($hWnd, $iIndex[, $fSelected = True[, $fFocused = False]])
默认$fFocused = False
设置$fFocused = true
_GUICtrlListView_SetItemSelected($ListView1, $y,True,True)
 楼主| 发表于 2009-12-18 10:59:51 | 显示全部楼层
这样设置过了,没用呢。`。`
 楼主| 发表于 2009-12-18 11:09:19 | 显示全部楼层
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 454, 192, 114)
$Input1 = GUICtrlCreateInput("hp", 64, 32, 169, 21, 0,0)
;GUICtrlSetBkColor(-1,0xECE9D8)
$ListView1 = GUICtrlCreateListView("test|gg", 48, 96, 321, 73)
GUICtrlCreateListViewItem("中国",$ListView1)
GUICtrlCreateListViewItem("中国",$ListView1)
GUICtrlCreateListViewItem("中国",$ListView1)
GUICtrlCreateListViewItem("中国",$ListView1)
GUICtrlCreateListViewItem("中国",$ListView1)
GUICtrlCreateListViewItem("中国",$ListView1)
GUICtrlCreateListViewItem("中国",$ListView1)
GUICtrlCreateListViewItem("中国",$ListView1)
GUICtrlCreateListViewItem("pp",$ListView1)
GUICtrlCreateListViewItem("中国",$ListView1)
GUICtrlCreateListViewItem("hp",$ListView1)
$button1 = GUICtrlCreateButton("发送",  168, 224, 177, 41)
GUICtrlSetState(-1, $GUI_FOCUS)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                case $Button1
                        $text =GUICtrlRead($input1)
                        $y=_GUICtrlListView_FindText($ListView1, $text)                                
                        _GUICtrlListView_SetItemSelected($ListView1, $y,True,True)
                        _GUICtrlListView_EnsureVisible($ListView1,  $y)                                                
                        
        EndSwitch
WEnd
请看看,这样选中的效果如下图




也不达到用鼠标选中时的状态那样

本帖子中包含更多资源

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

×
 楼主| 发表于 2009-12-18 11:19:14 | 显示全部楼层
已成功解决,呵呵。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-9 03:03 , Processed in 0.094232 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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