Sign in to follow this  
Followers 0
GodForsakenSoul

listview checkboxes

8 posts in this topic

well, i learned how to do checkboxes in listview, but i can't seem to read their state.

i tried GuiCtrlGetState(), but i got the integer 80 from it. whether it is checked or not, i got 80.

i trie GuiCtrlRead(), but got whatever it was in the listview, in the helpfile example case, "item3|col32|col33".

I don't seem to get this to work properly.

so... i need one of two things, either to figure out how to use the listview checkbox, or, aletrnatively, something else that works.

Share this post


Link to post
Share on other sites



Example from help file (_GUICtrlListView_GetItemChecked):

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>

Opt('MustDeclareVars', 1)

$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work

_Main()

Func _Main()
    Local $hListView
    
    GUICreate("ListView Get Item Checked State", 400, 300)
    $hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))
    GUISetState()
    
    ; Add columns
    _GUICtrlListView_AddColumn($hListView, "Column 1", 100)
    _GUICtrlListView_AddColumn($hListView, "Column 2", 100)
    _GUICtrlListView_AddColumn($hListView, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2)

    ; Check item 2
    _GUICtrlListView_SetItemChecked($hListView, 1)
    MsgBox(4160, "Information", "Item 2 Checked: " & _GUICtrlListView_GetItemChecked($hListView, 1))

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main

Best Regards BugFix  

Share this post


Link to post
Share on other sites

uh... huh... your example doesn't work. Error opening memory.au3

also, it doesn't let me play with the example. it automatically does #2, AND i don't like this particular line.

MsgBox(4160, "Information", "Item 2 Checked: " & _GUICtrlListView_GetItemChecked($hListView, 1))

your example has only been designed for item 2, despite whether or not you're willing to pick it.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Now i've modified it. So you can set checked and read check-state by yourself:

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>

Opt('MustDeclareVars', 1)

$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work

_Main()

Func _Main()
    Local $hListView, $btn, $state

    GUICreate("ListView Get Item Checked State", 400, 300)
    $hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))
    $btn = GUICtrlCreateButton('Check State', 160, 275, 80, 20)
    GUISetState()

    ; Add columns
    _GUICtrlListView_AddColumn($hListView, "Column 1", 100)
    _GUICtrlListView_AddColumn($hListView, "Column 2", 100)
    _GUICtrlListView_AddColumn($hListView, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2)

    ; Loop until user exits
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                GUIDelete()
                ExitLoop
            Case $btn
                $state = ''
                For $i = 0 To _GUICtrlListView_GetItemCount($hListView) -1
                    If _GUICtrlListView_GetItemChecked($hListView, $i) Then $state &= $i & ', '
                Next
                If $state <> '' Then MsgBox(0, '', 'Index checked Item: ' & StringTrimRight($state, 2))
        EndSwitch
    WEnd
EndFunc   ;==>_Main
Edited by BugFix

Best Regards BugFix  

Share this post


Link to post
Share on other sites

one last question: i want to analize (sp?) the UDF's myself.

i follow the "if you want something done right, you oughtta do it yourslef" thing.

i have never went so deep into autoit actually... where do i find these UDF's?

meanwhile, i shall play with your example.

Share this post


Link to post
Share on other sites

where do i find these UDF's?

Open the iclude file ( #include <GuiListView.au3> ).

To do this in SciTE: place cursor between the chars of this include-line. Than hit "Alt+i" - now the file will opened.


Best Regards BugFix  

Share this post


Link to post
Share on other sites

Than hit "Alt+i"

Wow, I learnt something today :graduated:


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

In addition to what BugFix posted, you can find all the standard UDFs in your AutoIt3\Include\ folder.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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