Jump to content
Sign in to follow this  

Checking ListViewItems

Recommended Posts


Hello, and the best of the festive season to all

I'm having trouble working out how to check if ListViewItems are checked or not.

The help file says this (my bolding):

For Listview items several states can be returned as $GUI_CHECKED and $GUI_UNCHECKED (only for listview controls with LVS_EX_CHECKBOXES-exstyle and on 'advanced' return) . So use i.e. BitAnd(GUICtrlRead($Item),$GUI_CHECKED) to test if the item is checked.

So, here is my code, but the msgbox comes up for each and every listviewitem, whether I have checked them or not.

Func _Do_Action($action)
    local $iCntr,$tmp

    for $iCntr = 1 to $maxActItems
        ;  $tmp = GUICtrlGetState($actItems[$iCntr])    ; I tried this - doesn't work
        $tmp = BitAnd(GUICtrlRead($actItems[$iCntr]),$GUI_CHECKED)   ; $tmp is always 1.
         if $tmp = 1 Then      ; the checkbox is checked
              msgbox(0,"Check","Item is checked " & GUICtrlRead($actItems[$iCntr]))

Any ideas?

Share this post

Link to post
Share on other sites

Nice one!

That did the job nicely.


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