Jump to content

_GUICtrlListView_GetItemChecked issue


Psibernetic
 Share

Recommended Posts

_GUICtrlListView_GetItemChecked is returning odd values for different circumstances, in this example I get a msgbox for array numbers 0-4 when i should only get what I have checked, can someone explain this to me?

#include <GuiConstants.au3>
#include <GuiListView.au3>

GUICreate("Monitor", 500, 250)

$Management_listview = GUICtrlCreateListView("Name|ID", 0, 75, 300, 88, $GUI_SS_DEFAULT_LISTVIEW, BitOR($LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT));Management_listview Construction
_GUICtrlListView_SetColumnWidth ($Management_listview, 0, 200)
_GUICtrlListView_SetColumnWidth ($Management_listview, 1, 95)

DIM $psi_ListViewItems[1]

_ArrayAdd($psi_ListViewItems, GUICtrlCreateListViewItem("zero|0", $Management_listview))
_ArrayAdd($psi_ListViewItems, GUICtrlCreateListViewItem("One|1", $Management_listview))
_ArrayAdd($psi_ListViewItems, GUICtrlCreateListViewItem("Two|2", $Management_listview))
_ArrayAdd($psi_ListViewItems, GUICtrlCreateListViewItem("Three|3", $Management_listview))

$Remove_playlist_button = GUICtrlCreateButton("Remove Playlist", 100, 0)

GUISetState(@SW_SHOW)

While 1
    $sys_msg = GUIGetMsg()
    
    Switch $sys_msg
        Case $Remove_playlist_button
            
            $count_index = 0
            
            While $count_index <= UBound($psi_ListViewItems)-1
                If _GUICtrlListView_GetItemChecked ($Management_listview, $psi_ListViewItems[$count_index]) = True Then
                    MsgBox(16, "0 Based Index item (TRUE)", $count_index)
                EndIf
                $count_index = $count_index + 1
            WEnd
            
            
        Case $Gui_event_close
            Exit
            
            
    EndSwitch
WEnd

Exit

[sup]Psibernetic[/sup]My Creations:X-HideSecuracy

Link to comment
Share on other sites

Can't use the control Id in lue of the index:

#include <GuiConstants.au3>
#include <GuiListView.au3>

GUICreate("Monitor", 500, 250)

$Management_listview = GUICtrlCreateListView("Name|ID", 0, 75, 300, 88, $GUI_SS_DEFAULT_LISTVIEW, BitOR($LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT));Management_listview Construction
_GUICtrlListView_SetColumnWidth($Management_listview, 0, 200)
_GUICtrlListView_SetColumnWidth($Management_listview, 1, 95)

Dim $psi_ListViewItems[1]

_ArrayAdd($psi_ListViewItems, GUICtrlCreateListViewItem("zero|0", $Management_listview))
_ArrayAdd($psi_ListViewItems, GUICtrlCreateListViewItem("One|1", $Management_listview))
_ArrayAdd($psi_ListViewItems, GUICtrlCreateListViewItem("Two|2", $Management_listview))
_ArrayAdd($psi_ListViewItems, GUICtrlCreateListViewItem("Three|3", $Management_listview))

$Remove_playlist_button = GUICtrlCreateButton("Remove Playlist", 100, 0)

GUISetState(@SW_SHOW)

While 1
    $sys_msg = GUIGetMsg()

    Switch $sys_msg
        Case $Remove_playlist_button

            For $count_index = 0 To UBound($psi_ListViewItems) - 1
                ConsoleWrite($psi_ListViewItems[$count_index] & @LF)
                If _GUICtrlListView_GetItemChecked($Management_listview, $count_index) = True Then
                    MsgBox(16, "0 Based Index item (TRUE)", $count_index)
                EndIf
            Next


        Case $Gui_event_close
            Exit


    EndSwitch
WEnd

Exit

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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...