找回密码
 加入
搜索
查看: 4469|回复: 11

[系统综合] 【已解决】ListView项移动问题

  [复制链接]
发表于 2011-1-2 13:38:01 | 显示全部楼层 |阅读模式
本帖最后由 ybbihsse 于 2011-1-3 22:23 编辑

如题,怎么把焦点移动到ListView列表项指定的项上
例如:ListView列中有140项数据,指定把焦点移到120项上

注:焦点没有在ListView控件上



答案在9楼
发表于 2011-1-2 17:16:01 | 显示全部楼层
_GUICtrlListView_SetItemFocused
 楼主| 发表于 2011-1-2 19:04:55 | 显示全部楼层
回复 2# netegg

这个要怎么用呀,为什么运行了,只是虚框上第二项上呀,而不是像鼠标点中有蓝底呀
#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>

Opt('MustDeclareVars', 1)

$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work

_Main()

Func _Main()
        Local $hListView
        
        GUICreate("ListView Set Item Focused", 400, 300)
        $hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
        GUISetState()

        ; Add columns
        _GUICtrlListView_AddColumn($hListView, "Column 1", 100)
        _GUICtrlListView_AddColumn($hListView, "Column 2", 100)
        _GUICtrlListView_AddColumn($hListView, "Column 3", 100)

        ; Add items
        _GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0)
        _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1)
        _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2)
        _GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1)
        _GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1)
        _GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2)

        ; Focus item 2
        _GUICtrlListView_SetItemFocused($hListView, 1)
        MsgBox(4160, "Information", "Item 2 Focused: " & _GUICtrlListView_GetItemFocused($hListView, 1))
        
        ; Loop until user exits
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
        GUIDelete()
EndFunc   ;==>_Main
怎么样才能实现上图的效果呀

本帖子中包含更多资源

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

×
发表于 2011-1-2 22:52:36 | 显示全部楼层
_GUICtrlListView_SetItemSelect
 楼主| 发表于 2011-1-3 11:46:33 | 显示全部楼层
回复 4# netegg


    呵呵,不行耶,能不能给个小小的例子让我参考下呀!!!
发表于 2011-1-3 12:09:08 | 显示全部楼层
_GUICtrlListView_SetItemFocused($hListView, 1)
MsgBox(4160, "Information", "Item 2 Focused: " & _GUICtrlListView_GetItemFocused($hListView, 1))这两行改成
_GUICtrlListView_SetItemSelected($hListView, 1)
MsgBox(4160, "Information", "Item 2 Focused: " & _GUICtrlListView_GetItemSelected($hListView, 1))看看
 楼主| 发表于 2011-1-3 14:07:08 | 显示全部楼层
回复 6# netegg


    可以是可以了,但是要是项目有好几百行,就会出现有滚动条,焦点上去了,但滚动条不会跟着滚~~~
发表于 2011-1-3 17:07:54 | 显示全部楼层
_GUICtrlListView_EnsureVisible($hWnd, $iIndex[, $fPartialOK = False])
 楼主| 发表于 2011-1-3 17:54:46 | 显示全部楼层
回复 8# netegg

不行,加上去没反应
发表于 2011-1-3 20:49:09 | 显示全部楼层
本帖最后由 netegg 于 2011-1-3 20:51 编辑

回复 9# ybbihsse
#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>

Opt('MustDeclareVars', 1)

$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work

_Main()

Func _Main()
        Local $hListView
        
        GUICreate("ListView Set Item Focused", 400, 300)
        $hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
        GUISetState()

        ; Add columns
        _GUICtrlListView_AddColumn($hListView, "Column 1", 100)
        _GUICtrlListView_AddColumn($hListView, "Column 2", 100)
        _GUICtrlListView_AddColumn($hListView, "Column 3", 100)

        For $i = 0 To 100
        _GUICtrlListView_AddItem($hListView, "Row 1: Col 1", $i)
        _GUICtrlListView_AddSubItem($hListView, $i, "Row 1: Col 2", 1)
        _GUICtrlListView_AddSubItem($hListView, $i, "Row 1: Col 3", 2)
                Next
        ; Focus item 2
        _GUICtrlListView_SetItemSelected($hListView, 50)
                _GUICtrlListView_EnsureVisible($hListView, 50)
        
        ; Loop until user exits
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
        GUIDelete()
EndFunc   ;==>_Main
 楼主| 发表于 2011-1-3 22:22:31 | 显示全部楼层
回复 10# netegg


    非常 感谢,真是个好人~~
发表于 2014-3-28 09:34:38 | 显示全部楼层
回复  ybbihsse
netegg 发表于 2011-1-3 20:49

不错的技巧,收藏了。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-28 11:21 , Processed in 0.122520 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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