maniootek

Multiple auto check select for list view items on single click

2 posts in this topic

#1 ·  Posted (edited)

When i combine style "$LVS_EX_CHECKBOXES" and "$LVS_EX_AUTOCHECKSELECT" it only check one item from list view. How to let it check more than one item?

#include <GUIConstantsEx.au3> ;for $GUI_EVENT_CLOSE
#include <GUIListView.au3>
Example()

Func Example()
    GUICreate("gui")
    Local $idListview = GUICtrlCreateListView("col1|col2|col3|", 10,10)
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOr($LVS_EX_CHECKBOXES, ,$LVS_EX_AUTOCHECKSELECT,$LVS_EX_AUTOSIZECOLUMNS, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))

    for $i=0 to 5
        GUICtrlCreateListViewItem($i & "|name|1" , $idListview)
    Next

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
EndFunc

Edited:

or is it possible only for Vista?

Quote

Global Const $LVS_EX_AUTOCHECKSELECT = 0x08000000 ; Vista - Automatically select check boxes on single click

 

Edited by maniootek

Share this post


Link to post
Share on other sites



maniootek,

As explained in the Help file, the ListView is created with the $LVS_SINGLESEL style as default. If you set the styles to remove that you can indeed select multiple items as long as you press the Ctrl key while so doing:

#include <GUIConstantsEx.au3> ;for $GUI_EVENT_CLOSE
#include <GUIListView.au3>
Example()

Func Example()
    GUICreate("gui")
    Local $idListview = GUICtrlCreateListView("col1|col2|col3|", 10, 10, 200, 200, $LVS_SHOWSELALWAYS)
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_CHECKBOXES, $LVS_EX_AUTOCHECKSELECT, $LVS_EX_AUTOSIZECOLUMNS, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))

    For $i = 0 To 5
        GUICtrlCreateListViewItem($i & "|name|1", $idListview)
    Next

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>Example

All the $LVS_EX_AUTOCHECKSELECT extended style appears to do is automatically check the checkbox when an item is selected - and limit checkbox visibility to selected items. Without it all checkboxes are permanently visible and are divorced from item selection. Either functionality may be useful may be useful depending on the particular case, but I am struggling to come up with a circumstance when I would wish to use this extended style.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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