Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Add Checkbox(s) in a GUI List

checkbox list

  • Please log in to reply
17 replies to this topic

#1 johnmcloud

johnmcloud

    Not an AutoIt MVPs (MVP)

  • Active Members
  • PipPipPipPipPipPip
  • 669 posts

Posted 02 July 2012 - 04:18 PM

Hi guys,
I have this script:

AutoIt         
#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 248, 180) $Edit = GUICtrlCreateEdit("", 8, 8, 233, 121) $Button = GUICtrlCreateButton("Save", 8, 136, 233, 33) GUISetState(@SW_SHOW) $TestFile = @WorkingDir & "Test.txt" FileOpen($TestFile, 2) FileWrite($TestFile, "Word_1" & @CRLF & "Word_2" & @CRLF & "Word_3" & @CRLF & "Word_4") GUICtrlSetData($Edit, FileRead($TestFile)) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button      FileDelete(@WorkingDir & "Result.txt")      FileWrite(@WorkingDir & "Result.txt", GUICtrlRead($Edit))      ShellExecute(@WorkingDir & "Result.txt") EndSwitch WEnd


I don't know how, i'd like to add a checkbox on every line of this list, so if i unchecked some and click on the button it save only the element with the checkbox enabled. I don't know how hany line has .txt, but i think we can read by array[0]

Hope I was clear, if not just ask and I'll try to post more information.

Thanks ;)

Edited by johnmcloud, 02 July 2012 - 04:22 PM.








#2 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 10,443 posts

Posted 02 July 2012 - 04:27 PM

Not possible in an Edit control, you can do it in a ListView control though.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to an XP machine, and I'm not going to.

 

Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude

 

How to ask questions the smart way!

 

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.
Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.
_FileGetProperty - Retrieve the properties of a file SciTE Toolbar - A toolbar demo for use with the SciTE editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.
GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips. Latin Square password generator

 

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.


#3 johnmcloud

johnmcloud

    Not an AutoIt MVPs (MVP)

  • Active Members
  • PipPipPipPipPipPip
  • 669 posts

Posted 02 July 2012 - 05:22 PM

Can you provide a simple script example like mine? It's better for me to understand. I think i can integrate a listview control in a GUI, right?
Thanks for your time.

#4 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,765 posts

Posted 02 July 2012 - 05:41 PM

Search this forum for $LVS_EX_CHECKBOXES
There are plenty of examples here for checkboxes in ListView

#5 DicatoroftheUSA

DicatoroftheUSA

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 556 posts

Posted 02 July 2012 - 07:29 PM

Below is a ruff script of what you could do. It gets buggy when you start scrolling, but there is a probably a workaround.


AutoIt         
#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include<array.au3> $Form1 = GUICreate("Form1", 248, 180) $Edit = GUICtrlCreateEdit("", 20, 8, 233, 121) $Button = GUICtrlCreateButton("Save", 8, 136, 233, 33) Local $iBoxes,$aBoxes[1], $sMSG, $iLines=1 GUISetState(@SW_SHOW) GUICtrlSetData($Edit,"a"&@crlf&"b"&@crlf&"c"&@crlf) While 1 $nMsg = GUIGetMsg() $aLines=StringRegExp(GUICtrlRead($Edit),"(.*)?(?:v)?",3) $iLines=UBound($aLines) $iBoxes= UBound($aBoxes) If $iBoxes>$iLines Then For $x=$iLines To UBound($aBoxes)-1 GUICtrlDelete($aBoxes[$x]) Next EndIf ReDim $aBoxes[$iLines] If $iBoxes<$iLines Then For $x=$iBoxes To UBound($aBoxes)-1 $aBoxes[$x-1]=GUICtrlCreateCheckbox("",2,($x-1)*14+8,14) GUICtrlSetState(-1,$GUI_CHECKED) Next EndIf Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Edit Case $Button $sMSG="" $aEdit=StringRegExp(GUICtrlRead($Edit),"(.*)?(?:v)?",3) For $x=0 To UBound($aBoxes)-1 If BitAnd(GUICtrlRead ($aBoxes[$x]),$GUI_CHECKED) Then $sMSG&=$aEdit[$x] EndIf Next MsgBox (0,"",$sMSG) EndSwitch WEnd

Edited by DicatoroftheUSA, 02 July 2012 - 07:32 PM.


#6 johnmcloud

johnmcloud

    Not an AutoIt MVPs (MVP)

  • Active Members
  • PipPipPipPipPipPip
  • 669 posts

Posted 03 July 2012 - 07:07 AM

Ok guys, for now i have make this:
AutoIt         
#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ListviewConstants.au3> Dim $item[6] = [5] GUICreate("Example", 216, 201, -1, -1, -1, $WS_EX_ACCEPTFILES) $listview = GUICtrlCreateListView("Name1", 10, 10, 192, 150, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_CHECKBOXES)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 185) $item[1] = GUICtrlCreateListViewItem("Select/Unselect All", $listview) $item[2] = GUICtrlCreateListViewItem("Word1", $listview) $item[3] = GUICtrlCreateListViewItem("Word2", $listview) $item[4] = GUICtrlCreateListViewItem("Word3", $listview) $item[5] = GUICtrlCreateListViewItem("Word4", $listview) $button = GUICtrlCreateButton("Save", 11, 162, 186, 20) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $button For $i = 1 To $item[0]     If BitAND(GUICtrlRead($item[$i], 1), $GUI_CHECKED) Then      FileDelete(@WorkingDir & "Test.txt")      FileWrite(@WorkingDir & "Test.txt", StringTrimRight(GUICtrlRead($item[$i]),1))      ShellExecute(@WorkingDir & "Test.txt") ;~   MsgBox(0, 0, GUICtrlRead($item[$i]), 2)     EndIf EndIf Next EndSwitch WEnd


There are a couple of problems:
1) This script not read the information from a file, the problem is not how to do, but i don't know how many item has the file. In the example are 4, but may be even 500
2) Click on checkbox "Select/Unselect All" and make it working, so if is selected, all are selected and viceversa

Thanks to all ;)

Edited by johnmcloud, 03 July 2012 - 07:08 AM.


#7 johnmcloud

johnmcloud

    Not an AutoIt MVPs (MVP)

  • Active Members
  • PipPipPipPipPipPip
  • 669 posts

Posted 03 July 2012 - 08:08 AM

I have resolved for the Select/Unselect all

Case $item[1] For $i = 2 To $item[0] If BitAND(GUICtrlRead($item[1], 1), $GUI_CHECKED) Then      GUICtrlSetState($item[$i], $GUI_CHECKED) Else      GUICtrlSetState($item[$i], $GUI_UNCHECKED) EndIf Next


But sometime seems not work...if you click fast.

And this part not work:
If BitAND(GUICtrlRead($item[$i], 1), $GUI_CHECKED) Then      FileDelete(@WorkingDir & "Test.txt")      FileWrite(@WorkingDir & "Test.txt", StringTrimRight(GUICtrlRead($item[$i]), 1))      ShellExecute(@WorkingDir & "Test.txt") ;~   MsgBox(0, 0, GUICtrlRead($item[$i]), 2) EndIf


And i need also only to know how read an unknow number of line from a txt...
Please some advice/example

Thanks

Edited by johnmcloud, 03 July 2012 - 08:27 AM.


#8 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,765 posts

Posted 03 July 2012 - 09:00 AM

For $i = 1 To $item[0]     If _GUICtrlListView_GetItemChecked($listview, $i-1) Then      FileDelete(@WorkingDir & "Test.txt")      ...


#9 johnmcloud

johnmcloud

    Not an AutoIt MVPs (MVP)

  • Active Members
  • PipPipPipPipPipPip
  • 669 posts

Posted 03 July 2012 - 09:07 AM

Not work:

Case $button For $i = 1 To $item[0]      If _GUICtrlListView_GetItemChecked($listview, $i-1) Then          FileDelete(@WorkingDir & "Test.txt")          FileWrite(@WorkingDir & "Test.txt", StringTrimRight(GUICtrlRead($item[$i]), 1))      EndIf Next ShellExecute(@WorkingDir & "Test.txt")


The .txt has only one element also if if select more, so if i select one work, but two or more not...

Edited by johnmcloud, 03 July 2012 - 09:09 AM.


#10 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,765 posts

Posted 03 July 2012 - 09:10 AM

Look here
http://www.autoitscript.com/wiki/Snippets_%28_Checkboxes_%29

#11 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,765 posts

Posted 03 July 2012 - 09:14 AM

Not work:
...

This works for me
         For $i = 1 To $item[0]                 If _GUICtrlListView_GetItemChecked($listview, $i - 1) Then                     ConsoleWrite(_GUICtrlListView_GetItemText($listview, $i - 1) & @CRLF)                 EndIf             Next


#12 johnmcloud

johnmcloud

    Not an AutoIt MVPs (MVP)

  • Active Members
  • PipPipPipPipPipPip
  • 669 posts

Posted 03 July 2012 - 09:17 AM

This works for me...

Also for me, but when i write on a file i have only one value. I need to use FileWrite?

 For $i = 1 To $item[0]      If _GUICtrlListView_GetItemChecked($listview, $i - 1) Then          FileDelete(@WorkingDir & "Test.txt")          FileWrite(@WorkingDir & "Test.txt", _GUICtrlListView_GetItemText($listview, $i - 1) & @CRLF)      EndIf Next ShellExecute(@WorkingDir & "Test.txt")

Edited by johnmcloud, 03 July 2012 - 09:21 AM.


#13 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,765 posts

Posted 03 July 2012 - 09:50 AM

FileDelete(@ScriptDir & "Test.txt") For $i = 1 To $item[0]      If _GUICtrlListView_GetItemChecked($listview, $i - 1) Then          FileWrite(@ScriptDir & "Test.txt", _GUICtrlListView_GetItemText($listview, $i - 1) & @CRLF)      EndIf Next ShellExecute(@ScriptDir & "Test.txt")  


#14 johnmcloud

johnmcloud

    Not an AutoIt MVPs (MVP)

  • Active Members
  • PipPipPipPipPipPip
  • 669 posts

Posted 03 July 2012 - 10:59 AM

Thanks Zedna, update:

AutoIt         
#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ListviewConstants.au3> #include <GuiListView.au3> Dim $item[6] = [5] GUICreate("Example", 216, 201, -1, -1, -1, $WS_EX_ACCEPTFILES) $iListView = GUICtrlCreateListView("Name1", 10, 10, 192, 150, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_CHECKBOXES)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 185) $hListView = GUICtrlGetHandle($iListView) $item[1] = GUICtrlCreateListViewItem("Select/Unselect All", $iListView) $item[2] = GUICtrlCreateListViewItem("Word1", $iListView) $item[3] = GUICtrlCreateListViewItem("Word2", $iListView) $item[4] = GUICtrlCreateListViewItem("Word3", $iListView) $item[5] = GUICtrlCreateListViewItem("Word4", $iListView) $button = GUICtrlCreateButton("Save", 11, 162, 186, 20) GUISetState(@SW_SHOW) For $i = 1 To $item[0] GUICtrlSetState($item[$i], $GUI_CHECKED) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $button FileOpen(@WorkingDir & "Test.txt", 2) For $i = 2 To $item[0]     If _GUICtrlListView_GetItemChecked($iListView, $i - 1) Then      FileWrite(@WorkingDir & "Test.txt", _GUICtrlListView_GetItemText($iListView, $i - 1) & @CRLF)     EndIf Next If _GUICtrlListView_AllUnChecked($hListView) = True Then     MsgBox(0, 0, "No element(s) selected") Else     ShellExecute(@WorkingDir & "Test.txt") EndIf Case $item[1] For $i = 2 To $item[0]     If BitAND(GUICtrlRead($item[1], 1), $GUI_CHECKED) Then      GUICtrlSetState($item[$i], $GUI_CHECKED)     Else      GUICtrlSetState($item[$i], $GUI_UNCHECKED)     EndIf Next EndSwitch WEnd Func _GUICtrlListView_AllUnChecked($hListView) Local $iChecked = 0, $iCount = _GUICtrlListView_GetItemCount($hListView) For $i = 0 To $iCount - 1 If Not _GUICtrlListView_GetItemChecked($hListView, $i) Then $iChecked += 1 EndIf Next Return $iChecked = $iCount ; Returns True - all items are unchecked or False - some are unchecked. EndFunc ;==>_GUICtrlListView_AllUnChecked


Problems:
1) The Func _GUICtrlListView_AllUnChecked read also the first line ( select/unselect all ), how to remove from the _GUICtrlListView_GetItemCount ?
2) Read the ListView information from a txt, without know the number of the item

Edited by johnmcloud, 03 July 2012 - 11:47 AM.


#15 johnmcloud

johnmcloud

    Not an AutoIt MVPs (MVP)

  • Active Members
  • PipPipPipPipPipPip
  • 669 posts

Posted 03 July 2012 - 01:20 PM

New update:

AutoIt         
#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ListviewConstants.au3> #include <GuiListView.au3> Dim $SelectAll[1] GUICreate("Example", 216, 201, -1, -1, -1, $WS_EX_ACCEPTFILES) $iListView = GUICtrlCreateListView("Name1", 10, 10, 192, 150, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_CHECKBOXES)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 185) $hListView = GUICtrlGetHandle($iListView) $SelectAll[0] = GUICtrlCreateListViewItem("Select/Unselect All", $iListView) $Button = GUICtrlCreateButton("Save", 11, 162, 186, 20) GUISetState(@SW_SHOW) File_Create() Load_Value() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button FileOpen(@WorkingDir & "Test.txt", 2) For $i = 2 To $SelectAll[0]     If _GUICtrlListView_GetItemChecked($iListView, $i - 1) Then      FileWrite(@WorkingDir & "Test.txt", _GUICtrlListView_GetItemText($iListView, $i - 1) & @CRLF)     EndIf Next If _GUICtrlListView_AllUnChecked($hListView) = True Then     MsgBox(0, 0, "No element(s) selected") Else     ShellExecute(@WorkingDir & "Test.txt") EndIf EndSwitch WEnd Func File_Create() $Test = FileOpen(@WorkingDir & "Test.txt", 2) FileWrite($Test, "Value11" & @LF & "Value22" & @LF & "Value33" & @LF & "Value44") EndFunc Func _GUICtrlListView_AllUnChecked($hListView) Local $iChecked = 1, $iCount = _GUICtrlListView_GetItemCount($hListView) For $i = 0 To $iCount - 1 If Not _GUICtrlListView_GetItemChecked($hListView, $i) Then $iChecked += 1 EndIf Next Return $iChecked = $iCount ; Returns True - all items are unchecked or False - some are unchecked. EndFunc ;==>_GUICtrlListView_AllUnChecked Func Load_Value() $File = FileRead(@WorkingDir & "Test.txt") $array = StringSplit($File, @LF) For $i = 1 To $array[0] - 1 GUICtrlCreateListViewItem(StringTrimRight($array[$i], 1), $iListView) Next EndFunc ;==>Load_Value


Now the script load the information from a txt ( remove last line and last letter of every line, but i need it )

I need to add only a working checkbox "Select/Unselect All"

Please :D

Edited by johnmcloud, 03 July 2012 - 01:26 PM.


#16 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,765 posts

Posted 03 July 2012 - 01:46 PM

I need to add only a working checkbox "Select/Unselect All"

Please :D


Search helpfile/forum for examples with _GUICtrlListView_SetItemChecked()

#17 johnmcloud

johnmcloud

    Not an AutoIt MVPs (MVP)

  • Active Members
  • PipPipPipPipPipPip
  • 669 posts

Posted 03 July 2012 - 03:20 PM

I think i'm not understand :(
I have not figured out how to apply it to my situation. I have no variables, I have only one value ($SelectAll), the others are generated from the contents of the file

So i want to click on "Select/Unselect All" checkbox, if checked the other are checked and viceversa.

The script, with the new button for load the value and one for save:
AutoIt         
#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ListviewConstants.au3> #include <GuiListView.au3> Dim $SelectAll[1]   $_1 = GUICreate("Example", 217, 202, -1, -1, -1, BitOR($WS_EX_ACCEPTFILES,$WS_EX_WINDOWEDGE)) $iListView = GUICtrlCreateListView("Name1", 10, 10, 192, 150, -1, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_CHECKBOXES)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 180) $hListView = GUICtrlGetHandle($iListView) $ButtonSave = GUICtrlCreateButton("Save", 107, 164, 92, 20) $ButtonLoad = GUICtrlCreateButton("Load", 19, 166, 84, 20) GUISetState(@SW_SHOW) File_Create() While 1 $nMsg = GUIGetMsg() Switch $nMsg   Case $GUI_EVENT_CLOSE    Exit   Case $ButtonLoad    $SelectAll[0] = GUICtrlCreateListViewItem("Select/Unselect All", $iListView)    Load_Value()   Case $ButtonSave    FileOpen(@WorkingDir & "Test.txt", 2)    For $i = 2 To $SelectAll[0]     If _GUICtrlListView_GetItemChecked($iListView, $i - 1) Then      FileWrite(@WorkingDir & "Test.txt", _GUICtrlListView_GetItemText($iListView, $i - 1) & @CRLF)     EndIf    Next    If _GUICtrlListView_AllUnChecked($hListView) = True Then     MsgBox(0, 0, "No element(s) selected")    Else     ShellExecute(@WorkingDir & "Test.txt")    EndIf EndSwitch WEnd Func File_Create() $Test = FileOpen(@WorkingDir & "Test.txt", 2) FileWrite($Test, "Value11" & @LF & "Value22" & @LF & "Value33" & @LF & "Value44") EndFunc   ;==>File_Create Func _GUICtrlListView_AllUnChecked($hListView) Local $iChecked = 1, $iCount = _GUICtrlListView_GetItemCount($hListView) For $i = 0 To $iCount - 1   If Not _GUICtrlListView_GetItemChecked($hListView, $i) Then    $iChecked += 1   EndIf Next Return $iChecked = $iCount ; Returns True - all items are unchecked or False - some are unchecked. EndFunc   ;==>_GUICtrlListView_AllUnChecked Func Load_Value() $File = FileRead(@WorkingDir & "Test.txt") $array = StringSplit($File, @LF) For $i = 1 To $array[0] - 1   GUICtrlCreateListViewItem(StringTrimRight($array[$i], 1), $iListView) Next EndFunc   ;==>Load_Value

Edited by johnmcloud, 03 July 2012 - 03:35 PM.


#18 johnmcloud

johnmcloud

    Not an AutoIt MVPs (MVP)

  • Active Members
  • PipPipPipPipPipPip
  • 669 posts

Posted 03 July 2012 - 06:14 PM

I think i have a solution:
AutoIt         
#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ListviewConstants.au3> #include <GuiListView.au3> Dim $SelectAll[1] $_1 = GUICreate("Example", 217, 202, -1, -1, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_WINDOWEDGE)) $iListView = GUICtrlCreateListView("Name1", 10, 10, 192, 150, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_CHECKBOXES)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 180) $hListView = GUICtrlGetHandle($iListView) $ButtonSave = GUICtrlCreateButton("Save", 107, 164, 92, 20) $ButtonLoad = GUICtrlCreateButton("Load", 19, 166, 84, 20) GUISetState(@SW_SHOW) File_Create() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ButtonLoad $SelectAll[0] = GUICtrlCreateListViewItem("Select/Unselect All", $iListView) Load_Value() Case $ButtonSave FileOpen(@WorkingDir & "Test.txt", 2) For $i = 2 To $SelectAll[0]     If _GUICtrlListView_GetItemChecked($iListView, $i - 1) Then      FileWrite(@WorkingDir & "Test.txt", _GUICtrlListView_GetItemText($iListView, $i - 1) & @CRLF)     EndIf Next If _GUICtrlListView_AllUnChecked($hListView) = True Then     MsgBox(0, 0, "No element(s) selected") Else     ShellExecute(@WorkingDir & "Test.txt") EndIf Case $SelectAll[0] If _GUICtrlListView_GetItemChecked($iListView, $SelectAll) Then _GUICtrlListView_SetItemChecked($iListView, $SelectAll[0], 1) _GUICtrlListView_SetCheckedStates($hListView, 1) EndIf If Not _GUICtrlListView_GetItemChecked($iListView, $SelectAll) Then _GUICtrlListView_SetItemChecked($iListView, $SelectAll, 2) _GUICtrlListView_SetCheckedStates($hListView, 2) EndIf EndSwitch WEnd Func File_Create() $Test = FileOpen(@WorkingDir & "Test.txt", 2) FileWrite($Test, "Value11" & @LF & "Value22" & @LF & "Value33" & @LF & "Value44") EndFunc ;==>File_Create Func _GUICtrlListView_AllUnChecked($hListView) Local $iChecked = 1, $iCount = _GUICtrlListView_GetItemCount($hListView) For $i = 0 To $iCount - 1 If Not _GUICtrlListView_GetItemChecked($hListView, $i) Then $iChecked += 1 EndIf Next Return $iChecked = $iCount ; Returns True - all items are unchecked or False - some are unchecked. EndFunc ;==>_GUICtrlListView_AllUnChecked Func Load_Value() $File = FileRead(@WorkingDir & "Test.txt") $array = StringSplit($File, @LF) For $i = 1 To $array[0] - 1 GUICtrlCreateListViewItem(StringTrimRight($array[$i], 1), $iListView) Next EndFunc ;==>Load_Value Func _GUICtrlListView_SetCheckedStates($hListView, $iType) ; By Zedna, Modified by guinness. Local $fState = False, $iCount = _GUICtrlListView_GetItemCount($hListView) If $iType < 0 Or $iType > 2 Then Return SetError(1, 0, 0) EndIf If $iType Then $fState = True EndIf For $i = 0 To $iCount - 1 If $iType = 2 Then $fState = Not _GUICtrlListView_GetItemChecked($hListView, $i) ; Invert checked state with $iType 2. EndIf _GUICtrlListView_SetItemChecked($hListView, $i, $fState) Next EndFunc ;==>_GUICtrlListView_SetCheckedStates


There is only a problem, if you click fast on checkbox "select/unselect all" sometimes lose the function. Someone what to test for search a workaround?
Thanks

Edited by johnmcloud, 03 July 2012 - 06:15 PM.






Also tagged with one or more of these keywords: checkbox, list

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users