Sign in to follow this  
Followers 0
zhaicheng

select an item in the list view in a sticky way

2 posts in this topic

Is there a way to make a click select an item in the list view and keep that item selected when another item is clicked? So, what I want is to single-click items in a list to select them, without needing to hold down the Ctrl or Shift keys.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

_GUICtrlListView_GetSelectedIndices ( ) function can help you ! Posted Image

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>

Global $hListView, $_Selection, $_SelectionOld
    
GUICreate("ListView Get Selected Indices", 400, 300)
$hListView = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT))
GUISetState()
_GUICtrlListView_AddColumn($hListView, "Column 1", 100)
_GUICtrlListView_AddItem($hListView, "Item 0")
_GUICtrlListView_AddItem($hListView, "Item 1")
_GUICtrlListView_AddItem($hListView, "Item 2")
_GUICtrlListView_SetItemSelected($hListView, 1)
_GUICtrlListView_SetItemSelected($hListView, 2)
    
Do
    $_Selection = _GUICtrlListView_GetSelectedIndices($hListView)
    If $_Selection <> '' And $_Selection <> $_SelectionOld Then
        MsgBox(4160, "Information", "Selected Indices: " & _GUICtrlListView_GetSelectedIndices($hListView))
        $_SelectionOld = $_Selection
    EndIf 
Until GUIGetMsg() = $GUI_EVENT_CLOSE

GUIDelete()
Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0