Sign in to follow this  
Followers 0
Floppy

ListView Checkboxes Problem

9 posts in this topic

Hi,

why this script doesn't work?

#include <GuiConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiListView.au3>
#include <ListviewConstants.au3>


$GUI = GUICreate("Test")
$check=GUICtrlCreateButton('check',10,10,100,20)

$ListView = GUICtrlCreateListView("Column1", 20, 40, 250, 250, -1, $LVS_EX_CHECKBOXES + $WS_EX_OVERLAPPEDWINDOW)
Dim $avLVItems[5]
For $i = 0 To 4
    $avLVItems[$i] = GUICtrlCreateListViewItem("Item" & $i, $ListView)
Next
GUISetState()

While 1
    $m=guigetmsg()
    Select
    Case $m=$GUI_EVENT_CLOSE
        Exit
    Case $m=$check
        For $h=0 To 4
            If GUICtrlGetState($avLVItems[$h])=$GUI_CHECKED Then MsgBox(0,'','Checked')
            Next
    EndSelect
    
WEnd

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Here..

#include <GuiConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiListView.au3>
#include <ListviewConstants.au3>


$GUI = GUICreate("Test")
$check=GUICtrlCreateButton('check',10,10,100,20)

$ListView = GUICtrlCreateListView("Column1", 20, 40, 250, 250, -1, $LVS_EX_CHECKBOXES + $WS_EX_OVERLAPPEDWINDOW)
Dim $avLVItems[5]
For $i = 0 To 4
    $avLVItems[$i] = GUICtrlCreateListViewItem("Item" & $i, $ListView)
Next
GUISetState()

While 1
    $m=guigetmsg()
    Select
    Case $m=$GUI_EVENT_CLOSE
        Exit
    Case $m=$check
        For $h=0 To 4
            If _GUICtrlListView_GetItemChecked($listview, $h)=True Then MsgBox(4096,"","checked " & "item "&$h)

            Next
    EndSelect
    WEnd
Edited by Manjish

[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com

Share this post


Link to post
Share on other sites

Here..

#include <GuiConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiListView.au3>
#include <ListviewConstants.au3>


$GUI = GUICreate("Test")
$check=GUICtrlCreateButton('check',10,10,100,20)

$ListView = GUICtrlCreateListView("Column1", 20, 40, 250, 250, -1, $LVS_EX_CHECKBOXES + $WS_EX_OVERLAPPEDWINDOW)
Dim $avLVItems[5]
For $i = 0 To 4
    $avLVItems[$i] = GUICtrlCreateListViewItem("Item" & $i, $ListView)
Next
GUISetState()

While 1
    $m=guigetmsg()
    Select
    Case $m=$GUI_EVENT_CLOSE
        Exit
    Case $m=$check
        For $h=0 To 4
            If _GUICtrlListView_GetItemChecked($listview, $h)=True Then MsgBox(4096,"","checked " & "item "&$h)

            Next
    EndSelect
    WEnd

Yes, but instead of typing _GUICtrlListView_GetItemChecked($listview, $h), is there a way to type _GUICtrlListView_GetItemChecked($listview, $avLVItems[3])?

Share this post


Link to post
Share on other sites

up

Share this post


Link to post
Share on other sites

Hi FSoft.. Didn't really understand ur question.. Please can u elaborate?


[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com

Share this post


Link to post
Share on other sites

Hi FSoft.. Didn't really understand ur question.. Please can u elaborate?

You write this For loop...

Case $m=$check
        For $h=0 To 4
            If _GUICtrlListView_GetItemChecked($listview, $h)=True Then MsgBox(4096,"","checked " & "item "&$h)

            Next

...to check if a item is checed or not.

_GUICtrlListView_GetItemChecked works only if you give it the index of the item.

My question is if there's a way to put the item's variable instead of its index.

I hope I made myself clear now.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I haven't tested this.. You can try it out:

if BitAnd($itemname,$gui_checked)=$gui_checked then ;put whatever u want here
Edited by Manjish

[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com

Share this post


Link to post
Share on other sites

I haven't tested this.. You can try it out:

if BitAnd($itemname,$gui_checked)=$gui_checked then ;put whatever u want here

No, it doesn't work.

Any other solution?

Share this post


Link to post
Share on other sites

#include <GuiConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <ListviewConstants.au3>

$GUI = GUICreate("Test")
$check = GUICtrlCreateButton('check', 10, 10, 100, 20)

$ListView = GUICtrlCreateListView("Column1", 20, 40, 250, 250, -1, BitOR($LVS_EX_CHECKBOXES, $WS_EX_OVERLAPPEDWINDOW))
Dim $avLVItems[5]
For $i = 0 To 4
    $avLVItems[$i] = GUICtrlCreateListViewItem("Item" & $i, $ListView)
Next
GUISetState()

While 1
    $m = GUIGetMsg()
    Select
        Case $m = $GUI_EVENT_CLOSE
            Exit
        Case $m = $check
            For $h = 0 To 4
                If BitAND(GUICtrlRead($avLVItems[$h], 1), $GUI_CHECKED) Then MsgBox(4096, "", "checked  " & "item " & $h & "  control-id " & $avLVItems[$h])
            Next
    EndSelect
WEnd

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