Jump to content

Listview read error


bordomavi
 Share

Go to solution Solved by Danyfirex,

Recommended Posts

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>

$Form1 = GUICreate("Form1", 320, 259, 192, 124)
Global $Checkbox1 = GUICtrlCreateCheckbox("Select All Items", 8, 24, 97, 17, BitOR($BS_3STATE,$WS_TABSTOP))
$test = GuiCtrlCreateButton("test all checked", 200, 24, 97, 17)
$ListView1 = GUICtrlCreateListView("Items", 8, 48, 297, 201)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100)
_GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))

$ListView1_0 = _GUICtrlListView_AddItem($ListView1,"one")
$ListView1_1 = _GUICtrlListView_AddItem($ListView1,"two")
$ListView1_2 = _GUICtrlListView_AddItem($ListView1,"three")
$ListView1_3 = _GUICtrlListView_AddItem($ListView1,"four")
$ListView1_4 = _GUICtrlListView_AddItem($ListView1,"five")

GUISetState(@SW_SHOW)

Global $allchecked = 0

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $test
            If GUICtrlRead($ListView1_0) = $GUI_CHECKED Then
               Msgbox(0,"", "")
            EndIf
        Case $Checkbox1
            If GUICtrlRead($Checkbox1) = $GUI_UNCHECKED Then
                GUICtrlSetState($Checkbox1, $GUI_CHECKED)
                For $C = 1 To _GUICtrlListView_GetItemCount($ListView1)
                    _GUICtrlListView_SetItemChecked($ListView1, $C - 1)
                Next
                $allchecked = 1
            ElseIf GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
                GUICtrlSetState($Checkbox1, $GUI_UNCHECKED)
                For $C = 1 To _GUICtrlListView_GetItemCount($ListView1)
                    _GUICtrlListView_SetItemChecked($ListView1, $C - 1, False)
                Next
                $allchecked = 0
            EndIf
    EndSwitch
WEnd

why case $test doesn't work

Link to comment
Share on other sites

?

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>

$Form1 = GUICreate("Form1", 320, 259, 192, 124)
Global $Checkbox1 = GUICtrlCreateCheckbox("Select All Items", 8, 24, 97, 17, BitOR($BS_3STATE, $WS_TABSTOP))
$test = GUICtrlCreateButton("test all checked", 200, 24, 97, 17)
$ListView1 = GUICtrlCreateListView("Items", 8, 48, 297, 201)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100)
_GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))

$ListView1_0 = _GUICtrlListView_AddItem($ListView1, "one")
$ListView1_1 = _GUICtrlListView_AddItem($ListView1, "two")
$ListView1_2 = _GUICtrlListView_AddItem($ListView1, "three")
$ListView1_3 = _GUICtrlListView_AddItem($ListView1, "four")
$ListView1_4 = _GUICtrlListView_AddItem($ListView1, "five")

GUISetState(@SW_SHOW)

Global $allchecked = 0

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $test
            If BitAND(GUICtrlRead($Checkbox1), $GUI_CHECKED) = $GUI_CHECKED Then
                MsgBox(0, "", "")
            EndIf
        Case $Checkbox1
            If BitAND(GUICtrlRead($Checkbox1), $GUI_UNCHECKED) = $GUI_UNCHECKED Then
                GUICtrlSetState($Checkbox1, $GUI_CHECKED)
                For $C = 1 To _GUICtrlListView_GetItemCount($ListView1)
                    _GUICtrlListView_SetItemChecked($ListView1, $C - 1)
                Next
                $allchecked = 1
            ElseIf BitAND(GUICtrlRead($Checkbox1), $GUI_CHECKED) = $GUI_CHECKED Then
                GUICtrlSetState($Checkbox1, $GUI_UNCHECKED)
                For $C = 1 To _GUICtrlListView_GetItemCount($ListView1)
                    _GUICtrlListView_SetItemChecked($ListView1, $C - 1, False)
                Next
                $allchecked = 0
            EndIf
    EndSwitch
WEnd

Visit my repository

Link to comment
Share on other sites

 

?

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>

$Form1 = GUICreate("Form1", 320, 259, 192, 124)
Global $Checkbox1 = GUICtrlCreateCheckbox("Select All Items", 8, 24, 97, 17, BitOR($BS_3STATE, $WS_TABSTOP))
$test = GUICtrlCreateButton("test all checked", 200, 24, 97, 17)
$ListView1 = GUICtrlCreateListView("Items", 8, 48, 297, 201)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100)
_GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))

$ListView1_0 = _GUICtrlListView_AddItem($ListView1, "one")
$ListView1_1 = _GUICtrlListView_AddItem($ListView1, "two")
$ListView1_2 = _GUICtrlListView_AddItem($ListView1, "three")
$ListView1_3 = _GUICtrlListView_AddItem($ListView1, "four")
$ListView1_4 = _GUICtrlListView_AddItem($ListView1, "five")

GUISetState(@SW_SHOW)

Global $allchecked = 0

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $test
            If BitAND(GUICtrlRead($Checkbox1), $GUI_CHECKED) = $GUI_CHECKED Then
                MsgBox(0, "", "")
            EndIf
        Case $Checkbox1
            If BitAND(GUICtrlRead($Checkbox1), $GUI_UNCHECKED) = $GUI_UNCHECKED Then
                GUICtrlSetState($Checkbox1, $GUI_CHECKED)
                For $C = 1 To _GUICtrlListView_GetItemCount($ListView1)
                    _GUICtrlListView_SetItemChecked($ListView1, $C - 1)
                Next
                $allchecked = 1
            ElseIf BitAND(GUICtrlRead($Checkbox1), $GUI_CHECKED) = $GUI_CHECKED Then
                GUICtrlSetState($Checkbox1, $GUI_UNCHECKED)
                For $C = 1 To _GUICtrlListView_GetItemCount($ListView1)
                    _GUICtrlListView_SetItemChecked($ListView1, $C - 1, False)
                Next
                $allchecked = 0
            EndIf
    EndSwitch
WEnd

i want it for $ListView1_0 not for  $Checkbox1 and i tried this $ListView1_0 it doesnt work

Link to comment
Share on other sites

  • Solution

Hi.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>

$Form1 = GUICreate("Form1", 320, 259, 192, 124)
Global $Checkbox1 = GUICtrlCreateCheckbox("Select All Items", 8, 24, 97, 17, BitOR($BS_3STATE,$WS_TABSTOP))
$test = GuiCtrlCreateButton("test all checked", 200, 24, 97, 17)
$ListView1 = GUICtrlCreateListView("Items", 8, 48, 297, 201)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100)
_GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))

$ListView1_0 = _GUICtrlListView_AddItem($ListView1,"one")
$ListView1_1 = _GUICtrlListView_AddItem($ListView1,"two")
$ListView1_2 = _GUICtrlListView_AddItem($ListView1,"three")
$ListView1_3 = _GUICtrlListView_AddItem($ListView1,"four")
$ListView1_4 = _GUICtrlListView_AddItem($ListView1,"five")

GUISetState(@SW_SHOW)

Global $allchecked = 0

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $test
            If _GUICtrlListView_GetItemChecked($ListView1,0) Then
               Msgbox(0,"", "")
            EndIf
        Case $Checkbox1
            If GUICtrlRead($Checkbox1) = $GUI_UNCHECKED Then
                GUICtrlSetState($Checkbox1, $GUI_CHECKED)
                For $C = 1 To _GUICtrlListView_GetItemCount($ListView1)
                    _GUICtrlListView_SetItemChecked($ListView1, $C - 1)
                Next
                $allchecked = 1
            ElseIf GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
                GUICtrlSetState($Checkbox1, $GUI_UNCHECKED)
                For $C = 1 To _GUICtrlListView_GetItemCount($ListView1)
                    _GUICtrlListView_SetItemChecked($ListView1, $C - 1, False)
                Next
                $allchecked = 0
            EndIf
    EndSwitch
WEnd

Saludos

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...