Jump to content

easy listView functions


nacerbaaziz
 Share

Recommended Posts

Hello guys
Today I'll give you three functions to manage the list View items

These functions will help you to do some works in your list view items
1. list view Read
To get the selected item text  
2. listView_checke
To checke an item
3. isListViewChecked
To see if the item is checked

All of these functions will be illustrated by the following example

You can download the include file from the link below
Now with the example

#include <easy_listView_functions.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
 Local $idListview

 GUICreate("ListView Get Item Checked State", 1000, 700)
 $idListview = GUICtrlCreateListView("", 50, 30, 250, 120, 50)
 _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))


; Add items
$item1 = GUICtrlCreateListViewItem("item1", $idListview)
$item2 = GUICtrlCreateListViewItem("item2", $idListview)
_listview_Checke($idListview, "item1")
$btn = GUICtrlCreateButton("&read", 100, 150, 50, 50)
$btn2 = GUICtrlCreateButton("&if checked", 100, 200, 100, 50)
 GUISetState(@SW_SHOW)

while 1
switch GUIGetMSG()
case $GUI_EVENT_CLOSE
 GUIDelete()
exit
case $btn
$read = _ListView_read($idListView)
if $read then
msgBox(0, "read listview", $read)
else
msgBox(0, "read listview", "no text ditected")
endIf
case $btn2
if _isListviewChecked($idListView, "item1") then
msgBox(0, "get", "the item is checked")
else
msgBox(0, "get", "the item isn't checked")
endIf


endSwitch
wend
EndFunc   ;==>Example


 

easy_listView_functions.au3

Edited by JLogan3o13
Added Code Formatting
Link to comment
Share on other sites

There are already functions for these actions, but thanks

_GUICtrlListView_GetItemText (use the second parameter for the index but GUICtrlRead(GUICtrlRead($ListView1) is probably quicker)

_GUICtrlListView_SetItemChecked()

_GUICtrlListView_GetItemChecked()

Just looked at the UDF and noticed you specify the item by text, so they are different to the AutoIt ones :thumbsup:

Edited by benners
Update
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

×
×
  • Create New...