Sign in to follow this  
Followers 0
Kovacic

GUIListViewEx.au3 | Clear the entire list with one button?

25 posts in this topic

Greetings, I cant post my code because its over 2000 lines and has mixed SQL queries that will give away too much company data, so I will juts post an example of GUIListViewEx:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $listview, $button, $item1, $item2, $item3, $item4, $msg
    GUICreate("Drop in Listview", 220, 200, 100, 100, -1, $WS_EX_ACCEPTFILES)
    $listview = GUICtrlCreateListView("col1|col2  ", 10, 10, 200, 150)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)
    $item1 = GUICtrlCreateListViewItem("1|4", $listview)
    $item2 = GUICtrlCreateListViewItem("2|5", $listview)
    $item3 = GUICtrlCreateListViewItem("3|6", $listview)
    GUISetState()

    Do
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_DROPPED
                GUICtrlCreateListViewItem(@GUI_DRAGFILE&'|', $listview)
        EndSelect
    Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Is it possible to easily empty the list with one simple button or function? I looked around the UDF and could not find anything but a single line delete.

Thanks in advance!


C0d3 is P0etry( ͡° ͜ʖ ͡°)

Share this post


Link to post
Share on other sites



True, I can do that, but if I have a list of over a thousand items, its going to delete line by line.. I was hoping to have more of a nuke approach. 


C0d3 is P0etry( ͡° ͜ʖ ͡°)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Use GUICtrlDelete to delete and then recreate the Control.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

The other issues is, with GUIListViewEx, if you have more than one list, they are numbered so you can activate them by index number depending on where you need to manipulate data, I will give it a try, but I'm afraid it will mess with my index numbers... 

Example:

Current lists:

Bulk hardware tab: list 1

Search results tab: list 2

if I delete and recreate list 1, will in come back as list 3?

I am thinking the delete line by line might be the best idea.


C0d3 is P0etry( ͡° ͜ʖ ͡°)

Share this post


Link to post
Share on other sites

Kovacic,

I wrote the UDF so I hope I will be able to give you an answer, but it is pretty late here so I will look into it tomorrow. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Hi. Use:

_GUICtrlListView_DeleteAllItems ($listview)

 

Edit:

as water and JohnOne say, it would be faster than I'm say.

Saludos

Edited by Danyfirex

Share this post


Link to post
Share on other sites

Does _GUICtrlListView_DeleteAllItems do it for you?


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 XP, 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!

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.

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 editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Does _GUICtrlListView_DeleteAllItems do it for you?

I did try this but it didn't seem to clear anything.

 

Kovacic,

I wrote the UDF so I hope I will be able to give you an answer, but it is pretty late here so I will look into it tomorrow. :)

M23

 

Thanks! Much appreciated!! :D

Edited by Kovacic

C0d3 is P0etry( ͡° ͜ʖ ͡°)

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

You should post an example of your listview using the actual GUIListViewEx functions, and how you attempted to delete the listview items. Currently you have a script posted that shows neither of these things.

 

EDIT: I just tested the _GUICtrlListView_DeleteAllItems function on one of the examples posted in the GUIListViewEx thread, and it worked flawlessly.

Edited by BrewManNH

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 XP, 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!

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.

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 editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Kovacic,

As I suspected it is not difficult to do. You need get the UDF to stop tracking the ListView in question with _GUIListViewEx_Close, empty it using the already suggested _GUICtrlListView_DeleteAllItems, and then re-initialise the ListView with _GUIListViewEx_Init using an empty array. :)

There is no problem with the index. Firstly, the UDF looks for the first blank element in the list, so the chances are that it will be the one you just closed and so it will use that and actually return the same index. Secondly, if you store the index in a variable then you can just reassign the new index to that variable and it really does not matter at all what the actual value is - I hope you were not hard coding it! :o

Here is an example script with 2 buttons which empty the 2 ListViews. Look for the <<<<<<<<<< section to see the code used:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

#include "GUIListViewEx.au3"

#include <Array.au3> ; Just for display in example

Opt("GUICloseOnESC", 0)

Global $iCount_Left = 20, $iCount_Right = 20, $vData, $sMsg, $aLV_List_Left, $aLV_List_Right, $aRet, $iEditMode = 0

; Create GUI
$hGUI = GUICreate("LVEx Example 1", 640, 510)

; Create Left ListView
GUICtrlCreateLabel("Native ListView" & @CRLF & "Multiple selection - no count - sort && editable (0 && 2)", 10, 5, 300, 30)

$cListView_Left = GUICtrlCreateListView("Tom|Dick|Harry", 10, 40, 300, 300, $LVS_SHOWSELALWAYS)
_GUICtrlListView_SetExtendedListViewStyle($cListView_Left, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_SetColumnWidth($cListView_Left, 0, 93)
_GUICtrlListView_SetColumnWidth($cListView_Left, 1, 93)
_GUICtrlListView_SetColumnWidth($cListView_Left, 2, 93)
; Set font
GUICtrlSetFont($cListView_Left, 12, Default, Default, "Courier New") ; Note edit control will use same font

; Create array and fill Left listview
Global $aLV_List_Left[$iCount_Left]
For $i = 0 To UBound($aLV_List_Left) - 1
    If Mod($i, 5) Then
        $aLV_List_Left[$i] = "Tom " & $i & "|Dick " & $i & "|Harry " & $i
    Else
        $aLV_List_Left[$i] = "Tom " & $i & "||Harry " & $i
    EndIf
    GUICtrlCreateListViewItem($aLV_List_Left[$i], $cListView_Left)
Next

; Initiate LVEx - use filling array - no count parameter - default insert mark colour (black) - drag image - sort & editable - only cols 0 & 2 (plus headers) editable
$iLV_Left_Index = _GUIListViewEx_Init($cListView_Left, $aLV_List_Left, 0, 0, True, 1 + 2 + 8, "0;2")

; Create Right ListView
GUICtrlCreateLabel("UDF ListView" & @CRLF & "Single sel - count element - editable (all)", 430, 5, 300, 30)

$hListView_Right = _GUICtrlListView_Create($hGUI, "", 430, 40, 200, 300, BitOR($LVS_DEFAULT, $WS_BORDER))
_GUICtrlListView_SetExtendedListViewStyle($hListView_Right, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_AddColumn($hListView_Right, "Peter", 83)
_GUICtrlListView_AddColumn($hListView_Right, "Paul", 83)
_GUICtrlListView_AddColumn($hListView_Right, "Mary", 83)

_GUICtrlListView_SetTextBkColor($hListView_Right, 0xDDFFDD)

; Fill Right ListView
For $i = 1 To $iCount_Right
    _GUICtrlListView_AddItem($hListView_Right, "Peter " & $i - 1)
    If Mod($i, 4) Then
        _GUICtrlListView_AddSubItem($hListView_Right, $i - 1, "Paul " & $i - 1, 1)
    EndIf
    _GUICtrlListView_AddSubItem($hListView_Right, $i - 1, "Mary " & $i - 1, 2)
Next

; Read array from Right  ListView
Global $aLV_List_Right = _GUIListViewEx_ReadToArray($hListView_Right, 1)
; The array as read from Right ListView and used subsequently
;_ArrayDisplay($aLV_List_Right, "Read from Right ListView")

; Initiate LVEx - use read content as array - count parameter set - red insert mark - drag image - editable - all cols editable by default (plus headers)
$iLV_Right_Index = _GUIListViewEx_Init($hListView_Right, $aLV_List_Right, 1, 0xFF0000, True, 2 + 4 + 8 + 16)

; Create Edit Mode Combos
GUICtrlCreateLabel("Edit Modes", 330, 50, 60, 20)
GUICtrlCreateLabel("0" & @CRLF & "1" & @CRLF & "2" & @CRLF & "3", 330, 70, 10, 80)
GUICtrlCreateLabel(":  Single Edit" & @CRLF & ":  Exit Edge" & @CRLF & ":  Stay Edge" & @CRLF & ":  Loop Edge", 340, 70, 65, 80)
GUICtrlCreateLabel("Row Mode", 330, 140, 60, 20)
$cCombo_Row = GUICtrlCreateCombo("", 330, 160, 75, 20, 0x3) ; $CBS_DROPDOWNLIST
GUICtrlSetData($cCombo_Row, "0|1|2|3", 0)
GUICtrlCreateLabel("Col Mode", 330, 200, 60, 20)
$cCombo_Col = GUICtrlCreateCombo("", 330, 220, 75, 20, 0x3) ; $CBS_DROPDOWNLIST
GUICtrlSetData($cCombo_Col, "0|1|2|3", 0)
GUICtrlCreateLabel("ESC Mode", 330, 260, 75, 20)
$cCombo_Reset = GUICtrlCreateCombo("", 330, 280, 75, 20, 0x3) ; $CBS_DROPDOWNLIST
GUICtrlSetData($cCombo_Reset, "Exit Edit|Reset All", "Exit Edit")

; Create buttons
$cInsert_Button = GUICtrlCreateButton("Insert", 10, 350, 200, 30)
$cDelete_Button = GUICtrlCreateButton("Delete", 10, 390, 200, 30)
$cUp_Button = GUICtrlCreateButton("Move Up", 220, 350, 200, 30)
$cDown_Button = GUICtrlCreateButton("Move Down", 220, 390, 200, 30)
$cEdit_Left_Button = GUICtrlCreateButton("Edit Left 1,1", 10, 430, 200, 30)
$cEdit_Right_Button = GUICtrlCreateButton("Edit Right 5,0", 220, 430, 200, 30)
$cDelAll_Left_Button = GUICtrlCreateButton("Delete All Left", 10, 470, 200, 30)
$cDelAll_Right_Button = GUICtrlCreateButton("Delete All Right", 220, 470, 200, 30)
$cDisplay_Left_Button = GUICtrlCreateButton("Show Left", 430, 350, 100, 30)
$cDisplay_Right_Button = GUICtrlCreateButton("Show Right", 530, 350, 100, 30)
$cExit_Button = GUICtrlCreateButton("Exit", 430, 390, 200, 110)

GUISetState()

; Register for sorting, dragging and editing
_GUIListViewEx_MsgRegister()

; Set the left ListView as active
_GUIListViewEx_SetActive($iLV_Left_Index)

Switch _GUIListViewEx_GetActive()
    Case 0
        $sMsg = "No ListView is active"
    Case 1
        $sMsg = "The LEFT ListView is active" & @CRLF & "<--------------------------"
    Case 2
        $sMsg = "The RIGHT ListView is active" & @CRLF & "---------------------------->"
EndSwitch
;MsgBox(0, "Active ListView", $sMsg)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $cExit_Button
            Exit

        Case $cInsert_Button
            ; Prepare data  for insertion
            Switch $aGLVEx_Data[0][1]
                Case 1
                    ; String format with multi-column native ListView
                    $vData = "Tom " & $iCount_Left & "|Dick " & $iCount_Left & "|Harry " & $iCount_Left
                    $iCount_Left += 1
                    _GUIListViewEx_Insert($vData)
                Case 2
                    ; Array format with multi-column UDF ListView
                    Global $vData[3] = ["Peter " & $iCount_Right, "Paul " & $iCount_Right, "Mary " & $iCount_Right]
                    $iCount_Right += 1
                    _GUIListViewEx_Insert($vData)
            EndSwitch

        Case $cDelete_Button
            _GUIListViewEx_Delete()

        Case $cUp_Button
            _GUIListViewEx_Up()

        Case $cDown_Button
            _GUIListViewEx_Down()

        Case $cDisplay_Left_Button

            $aLV_List_Left = _GUIListViewEx_ReturnArray($iLV_Left_Index)
            If Not @error Then
                _ArrayDisplay($aLV_List_Left, "Returned Left")
            Else
                MsgBox(0, "Left", "Empty Array")
            EndIf
            $aLV_List_Left = _GUIListViewEx_ReturnArray($iLV_Left_Index, 1)
            If Not @error Then
                _ArrayDisplay($aLV_List_Left, "Returned Left Checkboxes")
            Else
                MsgBox(0, "Left", "Empty Check Array")
            EndIf

        Case $cDisplay_Right_Button

            $aLV_List_Right = _GUIListViewEx_ReturnArray($iLV_Right_Index)
            If Not @error Then
                _ArrayDisplay($aLV_List_Right, "Returned Right")
            Else
                MsgBox(0, "Right", "Empty Array")
            EndIf

        Case $cEdit_Left_Button
            ; Note abilty to edit columns which cannot be edited via doubleclick
            $aRet = _GUIListViewEx_EditItem($iLV_Left_Index, 1, 1, $iEditMode) ; Use combos to change EditMode
            ; Check array exists
            If IsArray($aRet) Then
                ; Uncomment to see returned array
                ;_ArrayDisplay($aRet, @error)
            EndIf

        Case $cEdit_Right_Button
            $aHdr_Ret = _GUIListViewEx_EditItem($iLV_Right_Index, 5, 0, $iEditMode) ; Use combos to change EditMode
            $aRet = _GUIListViewEx_EditItem($iLV_Left_Index, 1, 1, $iEditMode) ; Use combos to change EditMode
            ; Check array exists
            If IsArray($aRet) Then
                ; Uncomment to see returned array
                ;_ArrayDisplay($aRet, @error)
            EndIf

        Case $cDelAll_Left_Button ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            ConsoleWrite("Prev Index = " & $iLV_Left_Index & @CRLF)
            ; Clear ListView from UDF
            _GUIListViewEx_Close($iLV_Left_Index)
            ; Delete all items
            _GUICtrlListView_DeleteAllItems($cListView_Left)
            ; Re-initiate ListView - no array
            $iLV_Left_Index = _GUIListViewEx_Init($cListView_Left, "", 0, 0, True, 1 + 2 + 8, "0;2")
            ConsoleWrite("New Index = " & $iLV_Left_Index & @CRLF)
            ; Activate ListView
            _GUIListViewEx_SetActive($iLV_Left_Index)


        Case $cDelAll_Right_Button
            ConsoleWrite("Prev Index = " & $iLV_Right_Index & @CRLF)
            ; Clear ListView from UDF
            _GUIListViewEx_Close($iLV_Right_Index)
            ; Delete all items
            _GUICtrlListView_DeleteAllItems($hListView_Right)
            ; Re-initiate ListView - no array
            $iLV_Right_Index = _GUIListViewEx_Init($hListView_Right, "", 1, 0xFF0000, True, 2 + 4 + 8 + 16)
            ConsoleWrite("New Index = " & $iLV_Right_Index & @CRLF)
            ; Activate ListView
            _GUIListViewEx_SetActive($iLV_Right_Index)

        Case $cCombo_Row
            Switch GUICtrlRead($cCombo_Row)
                Case 0
                    ; Both must be set to 0
                    GUICtrlSetData($cCombo_Col, 0)
                Case Else
                    ; Neither must be set to 0 - so match selections
                    If GUICtrlRead($cCombo_Col) = 0 Then
                        GUICtrlSetData($cCombo_Col, GUICtrlRead($cCombo_Row))
                    EndIf
            EndSwitch
            ; Set required edit mode
            $iEditMode = Number(GUICtrlRead($cCombo_Row) & GUICtrlRead($cCombo_Col))

        Case $cCombo_Col
            Switch GUICtrlRead($cCombo_Col)
                Case 0
                    GUICtrlSetData($cCombo_Row, 0)
                Case Else
                    If GUICtrlRead($cCombo_Row) = 0 Then
                        GUICtrlSetData($cCombo_Row, GUICtrlRead($cCombo_Col))
                    EndIf
            EndSwitch
            $iEditMode = Number(GUICtrlRead($cCombo_Row) & GUICtrlRead($cCombo_Col))

        Case $cCombo_Reset
            ; Toggle edit mode value to switch ESC modes
            $iEditMode *= -1

    EndSwitch

    $aRet = _GUIListViewEx_EditOnClick($iEditMode) ; Use combos to change EditMode
    ; Array only returned AFTER EditOnClick process - so check array exists
    If IsArray($aRet) Then
        ; Uncomment to see returned array
        ;_ArrayDisplay($aRet, @error)
    EndIf

WEnd
All clear? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Kovacic,

As I suspected it is not difficult to do. You need get the UDF to stop tracking the ListView in question with _GUIListViewEx_Close, empty it using the already suggested _GUICtrlListView_DeleteAllItems, and then re-initialise the ListView with _GUIListViewEx_Init using an empty array. :)

There is no problem with the index. Firstly, the UDF looks for the first blank element in the list, so the chances are that it will be the one you just closed and so it will use that and actually return the same index. Secondly, if you store the index in a variable then you can just reassign the new index to that variable and it really does not matter at all what the actual value is - I hope you were not hard coding it! :o

Here is an example script with 2 buttons which empty the 2 ListViews. Look for the <<<<<<<<<< section to see the code used:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

#include "GUIListViewEx.au3"

#include <Array.au3> ; Just for display in example

Opt("GUICloseOnESC", 0)

Global $iCount_Left = 20, $iCount_Right = 20, $vData, $sMsg, $aLV_List_Left, $aLV_List_Right, $aRet, $iEditMode = 0

; Create GUI
$hGUI = GUICreate("LVEx Example 1", 640, 510)

; Create Left ListView
GUICtrlCreateLabel("Native ListView" & @CRLF & "Multiple selection - no count - sort && editable (0 && 2)", 10, 5, 300, 30)

$cListView_Left = GUICtrlCreateListView("Tom|Dick|Harry", 10, 40, 300, 300, $LVS_SHOWSELALWAYS)
_GUICtrlListView_SetExtendedListViewStyle($cListView_Left, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_SetColumnWidth($cListView_Left, 0, 93)
_GUICtrlListView_SetColumnWidth($cListView_Left, 1, 93)
_GUICtrlListView_SetColumnWidth($cListView_Left, 2, 93)
; Set font
GUICtrlSetFont($cListView_Left, 12, Default, Default, "Courier New") ; Note edit control will use same font

; Create array and fill Left listview
Global $aLV_List_Left[$iCount_Left]
For $i = 0 To UBound($aLV_List_Left) - 1
    If Mod($i, 5) Then
        $aLV_List_Left[$i] = "Tom " & $i & "|Dick " & $i & "|Harry " & $i
    Else
        $aLV_List_Left[$i] = "Tom " & $i & "||Harry " & $i
    EndIf
    GUICtrlCreateListViewItem($aLV_List_Left[$i], $cListView_Left)
Next

; Initiate LVEx - use filling array - no count parameter - default insert mark colour (black) - drag image - sort & editable - only cols 0 & 2 (plus headers) editable
$iLV_Left_Index = _GUIListViewEx_Init($cListView_Left, $aLV_List_Left, 0, 0, True, 1 + 2 + 8, "0;2")

; Create Right ListView
GUICtrlCreateLabel("UDF ListView" & @CRLF & "Single sel - count element - editable (all)", 430, 5, 300, 30)

$hListView_Right = _GUICtrlListView_Create($hGUI, "", 430, 40, 200, 300, BitOR($LVS_DEFAULT, $WS_BORDER))
_GUICtrlListView_SetExtendedListViewStyle($hListView_Right, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_AddColumn($hListView_Right, "Peter", 83)
_GUICtrlListView_AddColumn($hListView_Right, "Paul", 83)
_GUICtrlListView_AddColumn($hListView_Right, "Mary", 83)

_GUICtrlListView_SetTextBkColor($hListView_Right, 0xDDFFDD)

; Fill Right ListView
For $i = 1 To $iCount_Right
    _GUICtrlListView_AddItem($hListView_Right, "Peter " & $i - 1)
    If Mod($i, 4) Then
        _GUICtrlListView_AddSubItem($hListView_Right, $i - 1, "Paul " & $i - 1, 1)
    EndIf
    _GUICtrlListView_AddSubItem($hListView_Right, $i - 1, "Mary " & $i - 1, 2)
Next

; Read array from Right  ListView
Global $aLV_List_Right = _GUIListViewEx_ReadToArray($hListView_Right, 1)
; The array as read from Right ListView and used subsequently
;_ArrayDisplay($aLV_List_Right, "Read from Right ListView")

; Initiate LVEx - use read content as array - count parameter set - red insert mark - drag image - editable - all cols editable by default (plus headers)
$iLV_Right_Index = _GUIListViewEx_Init($hListView_Right, $aLV_List_Right, 1, 0xFF0000, True, 2 + 4 + 8 + 16)

; Create Edit Mode Combos
GUICtrlCreateLabel("Edit Modes", 330, 50, 60, 20)
GUICtrlCreateLabel("0" & @CRLF & "1" & @CRLF & "2" & @CRLF & "3", 330, 70, 10, 80)
GUICtrlCreateLabel(":  Single Edit" & @CRLF & ":  Exit Edge" & @CRLF & ":  Stay Edge" & @CRLF & ":  Loop Edge", 340, 70, 65, 80)
GUICtrlCreateLabel("Row Mode", 330, 140, 60, 20)
$cCombo_Row = GUICtrlCreateCombo("", 330, 160, 75, 20, 0x3) ; $CBS_DROPDOWNLIST
GUICtrlSetData($cCombo_Row, "0|1|2|3", 0)
GUICtrlCreateLabel("Col Mode", 330, 200, 60, 20)
$cCombo_Col = GUICtrlCreateCombo("", 330, 220, 75, 20, 0x3) ; $CBS_DROPDOWNLIST
GUICtrlSetData($cCombo_Col, "0|1|2|3", 0)
GUICtrlCreateLabel("ESC Mode", 330, 260, 75, 20)
$cCombo_Reset = GUICtrlCreateCombo("", 330, 280, 75, 20, 0x3) ; $CBS_DROPDOWNLIST
GUICtrlSetData($cCombo_Reset, "Exit Edit|Reset All", "Exit Edit")

; Create buttons
$cInsert_Button = GUICtrlCreateButton("Insert", 10, 350, 200, 30)
$cDelete_Button = GUICtrlCreateButton("Delete", 10, 390, 200, 30)
$cUp_Button = GUICtrlCreateButton("Move Up", 220, 350, 200, 30)
$cDown_Button = GUICtrlCreateButton("Move Down", 220, 390, 200, 30)
$cEdit_Left_Button = GUICtrlCreateButton("Edit Left 1,1", 10, 430, 200, 30)
$cEdit_Right_Button = GUICtrlCreateButton("Edit Right 5,0", 220, 430, 200, 30)
$cDelAll_Left_Button = GUICtrlCreateButton("Delete All Left", 10, 470, 200, 30)
$cDelAll_Right_Button = GUICtrlCreateButton("Delete All Right", 220, 470, 200, 30)
$cDisplay_Left_Button = GUICtrlCreateButton("Show Left", 430, 350, 100, 30)
$cDisplay_Right_Button = GUICtrlCreateButton("Show Right", 530, 350, 100, 30)
$cExit_Button = GUICtrlCreateButton("Exit", 430, 390, 200, 110)

GUISetState()

; Register for sorting, dragging and editing
_GUIListViewEx_MsgRegister()

; Set the left ListView as active
_GUIListViewEx_SetActive($iLV_Left_Index)

Switch _GUIListViewEx_GetActive()
    Case 0
        $sMsg = "No ListView is active"
    Case 1
        $sMsg = "The LEFT ListView is active" & @CRLF & "<--------------------------"
    Case 2
        $sMsg = "The RIGHT ListView is active" & @CRLF & "---------------------------->"
EndSwitch
;MsgBox(0, "Active ListView", $sMsg)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $cExit_Button
            Exit

        Case $cInsert_Button
            ; Prepare data  for insertion
            Switch $aGLVEx_Data[0][1]
                Case 1
                    ; String format with multi-column native ListView
                    $vData = "Tom " & $iCount_Left & "|Dick " & $iCount_Left & "|Harry " & $iCount_Left
                    $iCount_Left += 1
                    _GUIListViewEx_Insert($vData)
                Case 2
                    ; Array format with multi-column UDF ListView
                    Global $vData[3] = ["Peter " & $iCount_Right, "Paul " & $iCount_Right, "Mary " & $iCount_Right]
                    $iCount_Right += 1
                    _GUIListViewEx_Insert($vData)
            EndSwitch

        Case $cDelete_Button
            _GUIListViewEx_Delete()

        Case $cUp_Button
            _GUIListViewEx_Up()

        Case $cDown_Button
            _GUIListViewEx_Down()

        Case $cDisplay_Left_Button

            $aLV_List_Left = _GUIListViewEx_ReturnArray($iLV_Left_Index)
            If Not @error Then
                _ArrayDisplay($aLV_List_Left, "Returned Left")
            Else
                MsgBox(0, "Left", "Empty Array")
            EndIf
            $aLV_List_Left = _GUIListViewEx_ReturnArray($iLV_Left_Index, 1)
            If Not @error Then
                _ArrayDisplay($aLV_List_Left, "Returned Left Checkboxes")
            Else
                MsgBox(0, "Left", "Empty Check Array")
            EndIf

        Case $cDisplay_Right_Button

            $aLV_List_Right = _GUIListViewEx_ReturnArray($iLV_Right_Index)
            If Not @error Then
                _ArrayDisplay($aLV_List_Right, "Returned Right")
            Else
                MsgBox(0, "Right", "Empty Array")
            EndIf

        Case $cEdit_Left_Button
            ; Note abilty to edit columns which cannot be edited via doubleclick
            $aRet = _GUIListViewEx_EditItem($iLV_Left_Index, 1, 1, $iEditMode) ; Use combos to change EditMode
            ; Check array exists
            If IsArray($aRet) Then
                ; Uncomment to see returned array
                ;_ArrayDisplay($aRet, @error)
            EndIf

        Case $cEdit_Right_Button
            $aHdr_Ret = _GUIListViewEx_EditItem($iLV_Right_Index, 5, 0, $iEditMode) ; Use combos to change EditMode
            $aRet = _GUIListViewEx_EditItem($iLV_Left_Index, 1, 1, $iEditMode) ; Use combos to change EditMode
            ; Check array exists
            If IsArray($aRet) Then
                ; Uncomment to see returned array
                ;_ArrayDisplay($aRet, @error)
            EndIf

        Case $cDelAll_Left_Button ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            ConsoleWrite("Prev Index = " & $iLV_Left_Index & @CRLF)
            ; Clear ListView from UDF
            _GUIListViewEx_Close($iLV_Left_Index)
            ; Delete all items
            _GUICtrlListView_DeleteAllItems($cListView_Left)
            ; Re-initiate ListView - no array
            $iLV_Left_Index = _GUIListViewEx_Init($cListView_Left, "", 0, 0, True, 1 + 2 + 8, "0;2")
            ConsoleWrite("New Index = " & $iLV_Left_Index & @CRLF)
            ; Activate ListView
            _GUIListViewEx_SetActive($iLV_Left_Index)


        Case $cDelAll_Right_Button
            ConsoleWrite("Prev Index = " & $iLV_Right_Index & @CRLF)
            ; Clear ListView from UDF
            _GUIListViewEx_Close($iLV_Right_Index)
            ; Delete all items
            _GUICtrlListView_DeleteAllItems($hListView_Right)
            ; Re-initiate ListView - no array
            $iLV_Right_Index = _GUIListViewEx_Init($hListView_Right, "", 1, 0xFF0000, True, 2 + 4 + 8 + 16)
            ConsoleWrite("New Index = " & $iLV_Right_Index & @CRLF)
            ; Activate ListView
            _GUIListViewEx_SetActive($iLV_Right_Index)

        Case $cCombo_Row
            Switch GUICtrlRead($cCombo_Row)
                Case 0
                    ; Both must be set to 0
                    GUICtrlSetData($cCombo_Col, 0)
                Case Else
                    ; Neither must be set to 0 - so match selections
                    If GUICtrlRead($cCombo_Col) = 0 Then
                        GUICtrlSetData($cCombo_Col, GUICtrlRead($cCombo_Row))
                    EndIf
            EndSwitch
            ; Set required edit mode
            $iEditMode = Number(GUICtrlRead($cCombo_Row) & GUICtrlRead($cCombo_Col))

        Case $cCombo_Col
            Switch GUICtrlRead($cCombo_Col)
                Case 0
                    GUICtrlSetData($cCombo_Row, 0)
                Case Else
                    If GUICtrlRead($cCombo_Row) = 0 Then
                        GUICtrlSetData($cCombo_Row, GUICtrlRead($cCombo_Col))
                    EndIf
            EndSwitch
            $iEditMode = Number(GUICtrlRead($cCombo_Row) & GUICtrlRead($cCombo_Col))

        Case $cCombo_Reset
            ; Toggle edit mode value to switch ESC modes
            $iEditMode *= -1

    EndSwitch

    $aRet = _GUIListViewEx_EditOnClick($iEditMode) ; Use combos to change EditMode
    ; Array only returned AFTER EditOnClick process - so check array exists
    If IsArray($aRet) Then
        ; Uncomment to see returned array
        ;_ArrayDisplay($aRet, @error)
    EndIf

WEnd
All clear? :)

M23

 

Much Thanks Melba!! I start working on this app again today at 1 EST and will let you know how it works out, but i'm sure it will be fine. 


C0d3 is P0etry( ͡° ͜ʖ ͡°)

Share this post


Link to post
Share on other sites

Im back ;)

Ok so for my function to clear a GUIListView ( ID number 2 ) I have this:

func ClearSearch() ; Clear search from tab 4
_GUIListViewEx_Close(2)
_GUICtrlListView_DeleteAllItems(2)
_GUIListViewEx_Init(2, "", 0, 0x00FF00)
endfunc

It closes the UDF functions from Index 2, then tries to clear all items, then re initializes the control, but it seems like its not doing anything to the list.

I know im missing something


C0d3 is P0etry( ͡° ͜ʖ ͡°)

Share this post


Link to post
Share on other sites

You need the handle or control ID of the listview, not sure what the 2 you're using is from.


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 XP, 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!

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.

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 editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Nevermind, cancel my last post! I used the Variable instead of the index and it worked perfect!!  

Thanks again!!


C0d3 is P0etry( ͡° ͜ʖ ͡°)

Share this post


Link to post
Share on other sites

Kovacic,

Glad it worked :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

OK so that worked... I am left with one more issue.. After I clear the form, if I do another search, it brings back the old data that was cleared out, and I broke it down to my one line item to add new data, the line that calls _GUIListViewEx_Insert

here is the function:

func ExSearch() ; Execute search for tab 4
MSGBOX(0,"DEBUG","THIS BOX IS ON LINE " & @ScriptLineNumber)
Local $zHe = 50, $Wze = 400
    Local $splash = GUICreate('', $Wze, $zHe, Default, Default, BitOR($WS_POPUP, $WS_BORDER), $WS_EX_TOPMOST)
    GUICtrlCreateGroup('SEARCHING...', 0, -5, $Wze, $zHe + 5, $WS_THICKFRAME)
    GUICtrlSetFont(-1, 14, 800, 0, "Arial", 5)
    GUICtrlCreateGroup('', -99, -99, 1, 1)
    GUICtrlCreateProgress(10, 20, 380, 25, 0x00000008)
    _SendMessage(GUICtrlGetHandle(-1), $PBM_SETMARQUEE, True, 50)
    ;GUISetState(@SW_SHOW, $splash)
    MSGBOX(0,"DEBUG","THIS BOX IS ON LINE " & @ScriptLineNumber)
$string = guictrlread($sbox)
MSGBOX(0,"DEBUG","THIS BOX IS ON LINE " & @ScriptLineNumber)
$object = guictrlread($SearchCombo)
MSGBOX(0,"DEBUG","THIS BOX IS ON LINE " & @ScriptLineNumber)
$conn.Open($DSN)
MSGBOX(0,"DEBUG","THIS BOX IS ON LINE " & @ScriptLineNumber)
    $rs = ObjCreate("ADODB.RecordSet")
    MSGBOX(0,"DEBUG","THIS BOX IS ON LINE " & @ScriptLineNumber)
    ;Msgbox(0,"EXECUTING","SELECT * FROM [v_master] where '" & $object & "'='" & $string & "';")
    $rs.Open("SELECT * FROM [v_master] where [" & $object & "]='" & $string & "';", $conn)
    MSGBOX(0,"DEBUG","THIS BOX IS ON LINE " & @ScriptLineNumber)
            _GUIListViewEx_Close($resultlist)
            _GUICtrlListView_DeleteAllItems($resultlist)
            _GUIListViewEx_Init($resultlist, "", 0, 0x00FF00)
            _GUIListViewEx_SetActive($resultlist)
            MSGBOX(0,"DEBUG","THIS BOX IS ON LINE " & @ScriptLineNumber)
    If $rs.RecordCount Then
    MSGBOX(0,"DEBUG","THIS BOX IS ON LINE " & @ScriptLineNumber)
        While Not $rs.EOF
        MSGBOX(0,"DEBUG","THIS BOX IS ON LINE " & @ScriptLineNumber)
        sleep(1000)
        MSGBOX(0,"DEBUG","THIS BOX IS ON LINE " & @ScriptLineNumber)
            $z1 = StringStripWS($rs.Fields("Serial Number").Value, 8)
            $z2 = StringStripWS($rs.Fields("Last User").Value, 8)
            $z3 = StringStripWS($rs.Fields("Owner").Value, 8)
            $z4 = StringStripWS($rs.Fields("Status").Value, 8)
            $z12 = StringStripWS($rs.Fields("Status").Value, 8)
            $z13 = StringStripWS($rs.Fields("Status").Value, 8)
            $z5 = StringStripWS($rs.Fields("Model").Value, 8)
            $z6 = StringStripWS($rs.Fields("Building").Value, 8)
            $z7 = StringStripWS($rs.Fields("Floor").Value, 8)
            $z8 = StringStripWS($rs.Fields("Side").Value, 8)
            $z9 = StringStripWS($rs.Fields("Area").Value, 8)
            $z10 = StringStripWS($rs.Fields("Unit").Value, 8)
            $z11 = StringStripWS($rs.Fields("Shelf").Value, 8)
MSGBOX(0,"DEBUG","THIS BOX IS ON LINE " & @ScriptLineNumber)
            _GUIListViewEx_Insert($z1 & " | " & $z2 & " | " & $z3 & " | " & $z4 & " | " & $z12 & " | " & $z13 & " | " & $z5 & " | " & $z6 & " | " & $z7 & " | " & $z8 & " | " & $z9 & " | " & $z10 & " | " & $z11)
    MSGBOX(0,"DEBUG","THIS BOX IS ON LINE " & @ScriptLineNumber)
            $rs.MoveNext
            MSGBOX(0,"DEBUG","THIS BOX IS ON LINE " & @ScriptLineNumber)
        WEnd
MSGBOX(0,"DEBUG","THIS BOX IS ON LINE " & @ScriptLineNumber)
    EndIf
    
;GUIDelete($splash)
endfunc

Ignore all the message boxes, they are just used to see where the values were coming back..

This line is what brings back the old data once its cleared:

_GUIListViewEx_Insert($z1 & " | " & $z2 & " | " & $z3 & " | " & $z4 & " | " & $z12 & " | " & $z13 & " | " & $z5 & " | " & $z6 & " | " & $z7 & " | " & $z8 & " | " & $z9 & " | " & $z10 & " | " & $z11)

and I am wondering if a value in the UDF is holding on to the previous values..


C0d3 is P0etry( ͡° ͜ʖ ͡°)

Share this post


Link to post
Share on other sites

Kovacic,

All that snippet tells me is that it should not work. ;)

_GUIListViewEx_Close($resultlist)                 ; Should be the index returned from _GUIListViewEx_Init
_GUICtrlListView_DeleteAllItems($resultlist)      ; Should be the handle/ControlID returned by GUICtrlCreateListView/_GUICrtlListView_Create
_GUIListViewEx_Init($resultlist, "", 0, 0x00FF00) ; Here you need to store the new index retuned by the function...
_GUIListViewEx_SetActive($resultlist)             ; ...which you then use here
So using the same variable for all of these is very unlikely to give you what you think you should get. Please ask if you do not understand my comments - they are pretty fundamental to the script working correctly. :)

 

I am wondering if a value in the UDF is holding on to the previous values

As you are reassigning those variables in the code I cannot believe that the UDF has anything to do with what you are seeing - all it does is track what you put into the ListView and you have just reintialised it with an empty array. The data you which you assign to those variables and then insert is coming from your database query - I suggest that is where you look. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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

  • Similar Content

    • Verssuss
      By Verssuss
      hello guys i have some problems. i never do it before but i need:
      1. simply way to save data from ListView to file and load it by button $button_load after i run program again. plz show me function
      2. is this possible to make button copy ? (selected items)
      3. is here way to add checkbox on each item ??

      here is my simple code.
      #AutoIt3Wrapper_UseX64=Y #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include "GUIListViewEx.au3" #include <Array.au3> ; Just for display in example #include <GUIConstants.au3> #include <ButtonConstants.au3> #include <SendMessage.au3> #include <GuiEdit.au3> #include <EditConstants.au3> $GUI = GUICreate("Story", 500, 400,200,200) GUISetState() $ListView = GUICtrlCreateListView("Name|ITEM|DMG|SPEED|PRICE", 10, 10, 300, 300, $LVS_SHOWSELALWAYS) $iLV_Index = _GUIListViewEx_Init($ListView, "", 0, 0, True, 1 + 2 + 8) _GUICtrlListView_SetExtendedListViewStyle($ListView, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES) $button_items = GUICtrlCreateButton("ADD ITEM", 350, 5, 90, 25) $button_random = GUICtrlCreateButton("ADD RANDOM", 350, 35, 90, 25) $button_up = GUICtrlCreateButton("UP", 350, 100, 50, 25) $button_down = GUICtrlCreateButton("DOWN", 350, 140, 50, 25) $button_copy = GUICtrlCreateButton("COPY", 350, 180, 50, 25) ; This is even possible tomake it work ?? $button_del_selected = GUICtrlCreateButton("DEL", 350, 220, 50, 25) $button_load = GUICtrlCreateButton("Load", 350, 300, 33, 30) $button_exit = GUICtrlCreateButton("Exit", 350, 330, 33, 30) Global $iCount = 0, $vData, $iEditMode = 0 _GUIListViewEx_MsgRegister() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $button_exit Exit Case $button_load _load() Case $button_random Global $vData[] = ["Name" & $iCount, "Sword", "450", "5", "3000$"] $iCount += 1 _GUIListViewEx_Insert($vData) Global $vData[] = ["Name" & $iCount, "Axe", "700", "2", "4500$"] $iCount += 1 _GUIListViewEx_Insert($vData) Global $vData[] = ["Name" & $iCount, "Bow", "300", "7", "2000$"] $iCount += 1 _GUIListViewEx_Insert($vData) Global $vData[] = ["Name" & $iCount, "Magic", "1000", "1", "6000$"] $iCount += 1 _GUIListViewEx_Insert($vData) Case $button_items gui2() GUICtrlSetState($GUI, $GUI_DISABLE) Case $button_del_selected _GUIListViewEx_Delete() Case $button_up _GUIListViewEx_SetActive($iLV_Index) _GUIListViewEx_Up() Case $button_down _GUIListViewEx_SetActive($iLV_Index) _GUIListViewEx_Down() EndSwitch $vRet = _GUIListViewEx_EventMonitor($iEditMode) WEnd Func gui2() $pos_GUI2 = WinGetPos($GUI) Local $GUI2 = GUICreate("Items", 300, 300, $pos_GUI2[0]+200, $pos_GUI2[1]+100,-1, $WS_EX_TOPMOST) Local $i1 = GUICtrlCreateInput("", 50, 30, 200, 25) Local $i2 = GUICtrlCreateInput("", 50, 60, 200, 25) Local $i3 = GUICtrlCreateInput("", 50, 90, 200, 25) Local $i4 = GUICtrlCreateInput("", 50, 120, 200, 25) Local $GUI2_button2 = GUICtrlCreateButton("ANULUJ", 80, 200, 50, 30) Local $GUI2_button1 = GUICtrlCreateButton("OK", 170, 200, 50, 30) Local $GUI2_label = GUICtrlCreateLabel("Write stats", 10, 5) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $GUI2_button2 GUIDelete($GUI2) GUICtrlSetState($GUI, $GUI_ENABLE) ExitLoop Case $GUI2_button1 Global $vData[] = ["Name" & $iCount, GUICtrlRead($i1), GUICtrlRead($i2), GUICtrlRead($i3), GUICtrlRead($i4)] $iCount += 1 _GUIListViewEx_Insert($vData) GUIDelete($GUI2) ExitLoop GUICtrlSetState($GUI, $GUI_ENABLE) EndSwitch WEnd EndFunc ;==>gui2 Func _quit() Exit EndFunc ;==>_quit Func _load() EndFunc ;==>_quit thanks u
       
    • david1337
      By david1337
      Hey guys
      I hope that I can get a little help with this one
       
      In this GUI example using GUIListViewEx, I have a list based on items found in test.txt.
      _____________________________________________
      item1
      item2
      item3
      ____________________________________________
      etc....
       
      When an item is selected, and I click the GetInfo button, a message will show the text of that item.
      Is it possible to activate a case like that as soon as the item is selected, so I don't need a button to start the case?
       
      #include <GUIConstantsEx.au3> #include <GUIListViewEx.au3> Global $MainGUI_ManageItemList Global $File = "test.txt" Global $FileToArray = FileReadToArray("test.txt") Call ("MainGUI_ManageItemList") Func MainGUI_ManageItemList() Local $Button1 $MainGUI_ManageItemList = GUICreate("Manage Item List", 800, 400, -1, -1) $cLV = GUICtrlCreateListView("[items]", 10, 10, 400, 775, $LVS_NOCOLUMNHEADER) GUICtrlSetFont(-1, 12, 800, 0, "@Arial Unicode MS") _GUICtrlListView_SetColumnWidth($cLV, 0, 378) $Button1 = GUICtrlCreateButton("Button 1", 425, 10, 80, 30) $RemoveItem = GUICtrlCreateButton("Remove Item", 425, 50, 80, 30) $GetInfo = GUICtrlCreateButton("GetInfo", 425, 120, 80, 30) GUISetState(@SW_SHOW, $MainGUI_ManageItemList) ; Intialise ListView Global $iLV_Index = _GUIListViewEx_Init($cLV) ; Insert lines _GUIListViewEx_Insert($FileToArray, True) ; Register required messages _GUIListViewEx_MsgRegister(True, False, False, False) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Button1 MsgBox(0,"","Button 1 is pressed") Case $RemoveItem _GUIListViewEx_Delete() Case $GetInfo $ItemSelected = _GUICtrlListView_GetSelectedIndices($cLV, True) If IsArray($ItemSelected) And $ItemSelected[0] <> 0 Then ;This part makes sure it doesn't crash when no item is selected. $ItemSelectedText = _GUICtrlListView_GetItemText($cLV, $ItemSelected[1]) msgbox (0, "Selected item", $ItemSelectedText) EndIf EndSwitch WEnd EndFunc ;==>Main  
    • shotiko
      By shotiko
      I have a problem using listview and arrays: I try to create listview from file which contains multiples of 3 lines, therefore 3 columns and rows of total number of lines devided on 3. creation works fine but it adds extra rows as as number of items: ex. 24 lines in text creates 3 columns 8rows and other 16 rows empty. this is seen in listview and adds scroll even though my gui shouldn't need.  I tried looking at styles and extended styles but couldn't find forcing limitation on number of rows created.
      Func _config() $configMain = GUICreate('Settings', 530, 330, -1, -1, '', '', $mainGUI) Global $editBtn = GUICtrlCreateButton("Edit", 430, 50, 70, 30); Edit Btn Global $saveBtn = GUICtrlCreateButton("Save", 430, 120, 70, 30); Save Btn Global $cancelBtn = GUICtrlCreateButton("Cancel", 430, 180, 70, 30); Cancel Btn ; create listview with 3 columns $cLV = GUICtrlCreateListView("Server Name|server address|user Name", 10, 10, 400, 280) GUICtrlSetFont(-1, 10); set font for previous control _GUICtrlListView_SetColumnWidth(-1, 0, 95); first column size _GUICtrlListView_SetColumnWidth(-1, 1, 180); second column size _GUICtrlListView_SetColumnWidth(-1, 2, 100); third column size Local $j = 1, $k = 2, $l = 3 ; starting lines for $j - server; $k - server address; $l - account name For $i = 1 To _FileCountLines($configF); 1 to number of lines present in file $sLine = FileReadLine($configF, $j); Server name Line read $saLine = FileReadLine($configF, $k); server address Line read $anLine = FileReadLine($configF, $l); user Name read $listV = GUICtrlCreateListViewItem($sLine & '|' & $saLine & '|' & $anLine, $cLV); assign 3 values each with iteration _ ; seperated and concatenated by '|' $j += 3; move three lines below $k += 3; move three lines below $l += 3; move three lines below Next $cLVarray = _GUIListViewEx_ReadToArray($cLV); read ListView to array $cLVinit = _GUIListViewEx_Init($cLV, $cLVarray, 0, 0, True, 1 + 2 + 512); Initialize _GUIListViewEx_SetEditStatus($cLVinit, "*") ; all columns can be edited _GUIListViewEx_MsgRegister() ; receive messages for UDF functions _GUIListViewEx_SetActive($cLVinit) ; set $cLVinit - 1 as active GUISetState(@SW_SHOW, $configMain) EndFunc ;==>_config  
      i can avoid this by
      For $i = 1 To 50 _GUICtrlListView_DeleteItem($cLV, 8) $i += 1 Next
      if i know maximum number of rows i will need, but items in listview are editable and therefore unreliable. I tried
      _GUICtrlListView_DeleteItem($cLV, _GUICtrlListView_GetItemCount($cLV) / _GUICtrlListView_GetColumnCount($cLV))
      this returns empty listview
      when it comes to editing part:
      $cLVarrayModif = _GUIListViewEx_ReturnArray($cLVinit, 0)
                       _ArrayDisplay($cLVarrayModif)
      this also shows 24 rows 3columns
    • marcoauto
      By marcoauto
      Ciao,
      I'm trying to filter a draggable Listview using checkbox, but when I filter a listview (idListiview) and I drag and drop a record to another listview, the listview that i filtered returns not filtered and the record that i would drag and drop is not the correct one
      There are 4 listview, LISTVIEWL1, LISTVIEWL2, LISTVIEWL3 and LISTVIEW. The filter must be work for LISTVIEW (and they work)
      Where I wrong?
      This is my script (Is not complete, but I rewrite it for the forum)
      I know that is not an optimized script...
       
      Thanks and sorry for my bad english
       
      Marco
       
      #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <GUIListView.au3> #include <EditConstants.au3> #include "GUIListViewEx.au3" #include <ButtonConstants.au3> #include <StaticConstants.au3> #include "_FileListToArrayEx_Marco.au3" #include <Array.au3> ; ******************************************************************************************************* ; **************************** LETTURA FILE CODICI DALLE CARTELLE *************************************** ; ******************************************************************************************************* ;~ $listaTotaleCodici = _FileListToArrayEx ("images", "*.png", 4);1+4); 1+4+128) ;<== original dim $listaTotaleCodici[11] $listaTotaleCodici[0] = 10 $listaTotaleCodici[1] = "01A_COD1_Tipo1_CHECK2_01_123456789_02_.png" $listaTotaleCodici[2] = "01A_COD2_Tipo1_CHECK3_02_321456789_01_.png" $listaTotaleCodici[3] = "02A_COD1_Tipo1_CHECK2_01_231456798_02_.png" $listaTotaleCodici[4] = "03A_COD1_Tipo2_CHECK1_01_888456789_01_.png" $listaTotaleCodici[5] = "04A_COD2_Tipo2_CHECK1_01_111456789_02_.png" $listaTotaleCodici[6] = "05A_COD1_Tipo1_CHECK2_01_777456789_02_.png" $listaTotaleCodici[7] = "05A_COD1_Tipo3_CHECK1_01_666456789_01_.png" $listaTotaleCodici[8] = "06A_COD1_Tipo1_CHECK2_01_555456789_02_.png" $listaTotaleCodici[9] = "07A_COD1_Tipo3_CHECK2_01_444456789_01_.png" $listaTotaleCodici[10] = "08A_COD1_Tipo1_CHECK2_01_666777789_02_.png" ;~ $listaTotaleCodici[11] = "08A_COD2_Tipo1_CHECK3_01_222456789_02_.png" ; read some png files ; Ex: ; 01A_COD_Tipo1_CHECK2_N_NUMBER_XY.png ; 02A_COD_Tipo1_CHECK2_N_NUMBER_XY.png ; 03A_COD_Tipo3_CHECK1_N_NUMBER_XY.png ; where NUMBER is differentfor any png files ; COD has max 2 values (COD1 or COD2) ; Tipo has max 3 values ; ******************************************************************************************************* ; ********************************* DICHIARAZIONI VARIABILI ********************************************* ; ******************************************************************************************************* dim $aArray[8] dim $filtrare[13] ;array dove vengono memorizzate le parole da filtrare (899, 01, webcom, ecc ecc) Global $fatto = 0 Global $iLV_L1,$iLV_L2,$iLV_L3,$iLV_Codici Dim $idItem[800] Dim $idItemL1[3] Dim $idItemL2[3] Dim $idItemL3[3] Global $idListviewL1, $idListviewL2, $idListviewL3, $idListview $x = 120 $y = 96 $offsetxpreview = 24+100 $offsetypreview = 129+96 $offsetx = $offsetxpreview + $x + 24 $offsety = 12 Global $offsetxradio = 345 Global $aList1, $tmp_String Dim $TotaleCodici[800] Dim $aTempArray[800] Dim $idButton[6] Global $offsetxbutton = 20 Global $offsetybutton = 45 Global $idx=0 Global $b = 0 Global $filtrato = 0 ; ******************************************************************************************************* ; **************************************** PARTENZA GDI ************************************************* ; ******************************************************************************************************* _GDIPlus_Startup() ;~ GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ; ******************************************************************************************************* ; *********************************** CREAZIONE GUI PRINCIPALE ****************************************** ; ******************************************************************************************************* $g_hGUI = GUICreate("GUI", 1038, 700, 192, 124) GUISetState() Global $Graphic = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ; ******************************************************************************************************* ; **************************************** CREAZIONE CHECKBOX ****************************************** ; ******************************************************************************************************* GUIStartGroup() $RadioCodice1 = GUICtrlCreateCheckbox("CHECK1", $offsetxradio+112, 10, 100, 17) GUICtrlSetState($RadioCodice1, $GUI_CHECKED) $RadioCodice2 = GUICtrlCreateCheckbox("CHECK2", $offsetxradio+227, 10, 100, 17) GUICtrlSetState($RadioCodice2, $GUI_CHECKED) $RadioCodice3 = GUICtrlCreateCheckbox("CHECK3", $offsetxradio+341, 10, 100, 17) GUICtrlSetState($RadioCodice3, $GUI_CHECKED) $Label1 = GUICtrlCreateLabel("LABEL:", $offsetxradio + 24 + 35, 10+2, 50, 17) $RadioTipo1 = GUICtrlCreateCheckbox("Tipo1", $offsetxradio+112, 45, 100, 17) GUICtrlSetState($RadioTipo1, $GUI_CHECKED) $RadioTipo2 = GUICtrlCreateCheckbox("Tipo2", $offsetxradio+227, 45, 100, 17) GUICtrlSetState($RadioTipo2, $GUI_CHECKED) $RadioTipo3 = GUICtrlCreateCheckbox("Tipo3", $offsetxradio+341, 45, 100, 17) GUICtrlSetState($RadioTipo3, $GUI_CHECKED) $LabelTipo = GUICtrlCreateLabel("TIPO:", $offsetxradio + 24 + 35, 45+2, 50, 17) Global $offsetxradio = 345 ;~ GUIStartGroup() $Radio1 = GUICtrlCreateCheckbox("A", $offsetxradio+112, 80, 50, 17) ;~ Local $idCheckbox = GUICtrlCreateCheckbox("Standard Checkbox", 10, 10, 185, 25) GUICtrlSetState($Radio1, $GUI_CHECKED) $Radio2 = GUICtrlCreateCheckbox("B", $offsetxradio+169, 80, 50, 17) GUICtrlSetState($Radio2, $GUI_CHECKED) $Radio3 = GUICtrlCreateCheckbox("C", $offsetxradio+227, 80, 50, 17) GUICtrlSetState($Radio3, $GUI_CHECKED) $Radio4 = GUICtrlCreateCheckbox("D", $offsetxradio+284, 80, 50, 17) GUICtrlSetState($Radio4, $GUI_CHECKED) $Radio5 = GUICtrlCreateCheckbox("E", $offsetxradio+341, 80, 50, 17) GUICtrlSetState($Radio5, $GUI_CHECKED) $Radio6 = GUICtrlCreateCheckbox("F", $offsetxradio+399, 80, 50, 17) GUICtrlSetState($Radio6, $GUI_CHECKED) $Radio7 = GUICtrlCreateCheckbox("ALL", $offsetxradio+456, 80, 50, 17) GUICtrlSetState($Radio7, $GUI_CHECKED) $LabelGruppi = GUICtrlCreateLabel("LABEL:", $offsetxradio + 24 + 35, 80+2, 50, 17) $ButtonFiltra = GUICtrlCreateButton("Filter", 870, 12, 150, 84) ;~ GUICtrlSetBkColor(-1,0x00FF00 $hGraphic = _GDIPlus_GraphicsCreateFromHWND($Graphic) $hPen = _GDIPlus_PenCreate(0xff000000, 2);red, 3pixels wide ; ******************************************************************************************************* ; **************************************** CREAZIONE BOTTONI ******************************************* ; ******************************************************************************************************* $cDelete_Button = GUICtrlCreateButton("Delete Line", 870, 115, 150, 30) $idListviewL1 = GUICtrlCreateListView("LISTVIEWL1", 400, 6+96, 450, 96) _GUICtrlListView_SetColumnWidth($idListviewL1, 0, 446) $idListviewL2 = GUICtrlCreateListView("LISTVIEWL2", 400, 6+96+96, 450, 96) _GUICtrlListView_SetColumnWidth($idListviewL2, 0, 446) $idListviewL3 = GUICtrlCreateListView("LISTVIEWL3", 400, 6+96+96+96, 450, 96) _GUICtrlListView_SetColumnWidth($idListviewL3, 0, 446) $idListview = GUICtrlCreateListView("LISTVIEW", 400, 6+96+96+96+96, 450, 573-96-96-96) _GUICtrlListView_SetColumnWidth($idListview, 0, 446) if $fatto = 0 Then ConsoleWrite("fatto = 0" & @CRLF) For $i = 1 To $listaTotaleCodici[0] ; Loop through the array to display the individual values. local $aArray = StringSplit($listaTotaleCodici[$i], '_');, $STR_ENTIRESPLIT) ; Pass the variable to StringSplit and using the delimiter "\n". Local $aList[$listaTotaleCodici[0]+1], $sText If IsArray($aArray) Then $sText = $aArray[1] & " " & $aArray[2] & " " & $aArray[3] & " " & $aArray[4] & " " & $aArray[6] $aList[$i] = $sText GUICtrlCreateListViewItem($sText, $idListview) EndIf Next $iLV_Codici = _GUIListViewEx_Init($idListview, $aList, 0, 0, True, 128 + 256) $TotaleEtichetteCodici = _GUIListViewEx_ReadToArray($idListview) $fatto = 1 EndIf $iLV_L1 = _GUIListViewEx_Init($idListviewL1, $idItemL1, 0, 0, True) ; No external drop, will drag to others - items deleted on drag $iLV_L2 = _GUIListViewEx_Init($idListviewL2, $idItemL2, 0, 0, True) ; No external drop, will drag to others - items deleted on drag $iLV_L3 = _GUIListViewEx_Init($idListviewL3, $idItemL3, 0, 0, True) ; No external drop, will drag to others - items deleted on drag ;~ $iLV_Codici = _GUIListViewEx_Init($idListview, $idItem, 0, 0, True, 128 + 256) ; No external drop, will drag to others - items NOT deleted on drag ;~ GUISetState() _GUIListViewEx_MsgRegister() _GUICtrlListView_SetColumnWidth($idListview, 0, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($idListview, 1, 1) ; <<<<<<<<<<<<<<<<<<<<<<<<<< GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ; ******************************************************************************************************* ; ********************************************* MAIN LOOP *********************************************** ; ******************************************************************************************************* Global $idMsg ;~ ; Loop until the user exits. While 1 Sleep(10) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $cDelete_Button $listaTotaleCodiciaAttiva = _GUIListViewEx_GetActive() ConsoleWrite(" active = " & $listaTotaleCodiciaAttiva & @CRLF) if $listaTotaleCodiciaAttiva <> 1 Then _GUIListViewEx_Delete() EndIf Case $ButtonFiltra _filtraCodici() EndSwitch WEnd ; Clean up resources _GDIPlus_GraphicsDispose($Graphic) _GDIPlus_Shutdown() ; ******************************************************************************************************* ; ***************************************** QUIT FUNCTION *********************************************** ; ******************************************************************************************************* Func Quit() _GDIPlus_Shutdown() Exit EndFunc ; ******************************************************************************************************* ; **************************************** ISCHECKED FUNCTION ******************************************* ; ******************************************************************************************************* Func _IsChecked($idControlID) Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_IsChecked ; ******************************************************************************************************* ; ************************************ WM_NOTIFY FUNCTION *********************************************** ; ******************************************************************************************************* Func WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam) _GUIListViewEx_WM_NOTIFY_Handler($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local $index $tStruct = DllStructCreate("hwnd;uint_ptr;int_ptr;int;int", $lParam) $hWndFrom = DllStructGetData($tStruct, 1) $idFrom = DllStructGetData($tStruct, 2) $code = DllStructGetData($tStruct, 3) $index = DllStructGetData($tStruct, 4) $hWndListView1 = GUICtrlGetHandle($iLV_L1) ;($idListviewL1) $hWndListView2 = GUICtrlGetHandle($iLV_L2) ;($idListviewL2) $hWndListView3 = GUICtrlGetHandle($iLV_L3) ;($idListviewL3) $hWndListViewCodici = GUICtrlGetHandle($iLV_Codici) ;($idListview) Switch $code Case $NM_CLICK ;Left Mouse Button ConsoleWrite("left mouse button") Switch $idFrom Case $iLV_L1 $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) ;~ ConsoleWrite("+Click: " & $index & @CRLF) $text = _GUICtrlListView_GetItemText($iLV_L1, DllStructGetData($tInfo, "Index")) ConsoleWrite("+text: " & $text & @CRLF) EndSwitch Case $NM_DBLCLK ;Double Left Mouse Button Switch $idFrom Case $idListviewL1 $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) ;~ ConsoleWrite("+Click: " & $index & @CRLF) $text = _GUICtrlListView_GetItemText($idListviewL1, DllStructGetData($tInfo, "Index")) ConsoleWrite("+textDBClick: " & $text & @CRLF) Case $idListview $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) ;~ ConsoleWrite("+Click: " & $index & @CRLF) $text = _GUICtrlListView_GetItemText($idListview, DllStructGetData($tInfo, "Index")) ConsoleWrite("+textDBClick: " & $text & @CRLF) EndSwitch Case $GUI_EVENT_CLOSE Quit() EndSwitch EndFunc ;==>WM_NOTIFY ; ******************************************************************************************************* ; ***************************************** FILTRA CODICI *********************************************** ; ******************************************************************************************************* Func _filtraCodici() $aTempArray = $TotaleEtichetteCodici ;$listaTotaleCodici Local $filtrato = 0 If _IsChecked($Radio1) Then $filtrare[1] = 1 Else $filtrare[1] = "A" $filtrato = 1 For $b=UBound($aTempArray) -1 to 0 step -1 Global $tmp_String = StringLeft($aTempArray[$b][0],3) If StringInStr($tmp_String,$filtrare[1]) Then _ArrayDelete($aTempArray, $b) EndIf Next EndIf If _IsChecked($Radio2) Then $filtrare[2] = 1 Else $filtrare[2] = "B" $filtrato = 1 For $b=UBound($aTempArray) -1 to 0 step -1 Global $tmp_String = StringLeft($aTempArray[$b][0],3) If StringInStr($tmp_String,$filtrare[2]) Then _ArrayDelete($aTempArray, $b) EndIf Next EndIf If _IsChecked($Radio3) Then $filtrare[3] = 1 Else $filtrare[3] = "C" $filtrato = 1 For $b=UBound($aTempArray) -1 to 0 step -1 Global $tmp_String = StringLeft($aTempArray[$b][0],3) If StringInStr($tmp_String,$filtrare[3]) Then _ArrayDelete($aTempArray, $b) EndIf Next EndIf If _IsChecked($Radio4) Then $filtrare[4] = 1 Else $filtrare[4] = "D" $filtrato = 1 For $b=UBound($aTempArray) -1 to 0 step -1 Global $tmp_String = StringLeft($aTempArray[$b][0],3) If StringInStr($tmp_String,$filtrare[4]) Then _ArrayDelete($aTempArray, $b) EndIf Next EndIf If _IsChecked($Radio5) Then $filtrare[5] = 1 Else $filtrare[5] = "E" $filtrato = 1 For $b=UBound($aTempArray) -1 to 0 step -1 Global $tmp_String = StringLeft($aTempArray[$b][0],3) If StringInStr($tmp_String,$filtrare[5]) Then _ArrayDelete($aTempArray, $b) EndIf Next EndIf If _IsChecked($Radio6) Then $filtrare[6] = 1 Else $filtrare[6] = "F" $filtrato = 1 For $b=UBound($aTempArray) -1 to 0 step -1 Global $tmp_String = StringLeft($aTempArray[$b][0],3) If StringInStr($tmp_String,$filtrare[6]) Then _ArrayDelete($aTempArray, $b) EndIf Next EndIf If _IsChecked($RadioTipo1) Then $filtrare[7] = 1 Else $filtrare[7] = "Tipo1" $filtrato = 1 For $b=UBound($aTempArray) -1 to 0 step -1 Global $tmp_String = $aTempArray[$b][0] If StringInStr($tmp_String,$filtrare[7]) Then _ArrayDelete($aTempArray, $b) EndIf Next EndIf If _IsChecked($RadioTipo2) Then $filtrare[8] = 1 Else $filtrare[8] = "Tipo2" $filtrato = 1 For $b=UBound($aTempArray) -1 to 0 step -1 $tmp_String = $aTempArray[$b][0] If StringInStr($tmp_String,$filtrare[8]) Then _ArrayDelete($aTempArray, $b) EndIf Next EndIf If _IsChecked($RadioTipo3) Then $filtrare[9] = 1 Else $filtrare[9] = "Tipo3" $filtrato = 1 For $b=UBound($aTempArray) -1 to 0 step -1 $tmp_String = $aTempArray[$b][0] If StringInStr($tmp_String,$filtrare[9]) Then _ArrayDelete($aTempArray, $b) EndIf Next EndIf If _IsChecked($RadioCodice1) Then $filtrare[10] = 1 Else $filtrare[10] = "CHECK1" $filtrato = 1 For $b=UBound($aTempArray) -1 to 0 step -1 Global $tmp_String = $aTempArray[$b][0] If StringInStr($tmp_String,$filtrare[10]) Then _ArrayDelete($aTempArray, $b) EndIf Next EndIf If _IsChecked($RadioCodice2) Then $filtrare[11] = 1 Else $filtrare[11] = "CHECK2" $filtrato = 1 For $b=UBound($aTempArray) -1 to 0 step -1 Global $tmp_String = $aTempArray[$b][0] ;~ ConsoleWrite(@CRLF & "$tmp_Stringgg= " & $tmp_String & @CRLF) If StringInStr($tmp_String,$filtrare[11]) Then _ArrayDelete($aTempArray, $b) EndIf Next EndIf If _IsChecked($RadioCodice3) Then $filtrare[12] = 1 Else $filtrare[12] = "CHECK3" $filtrato = 1 For $b=UBound($aTempArray) -1 to 0 step -1 Global $tmp_String = $aTempArray[$b][0] ;~ ConsoleWrite(@CRLF & "$tmp_Stringgg= " & $tmp_String & @CRLF) If StringInStr($tmp_String,$filtrare[12]) Then _ArrayDelete($aTempArray, $b) EndIf Next EndIf _ArrayDisplay($aTempArray,"fine ciclo") _GUICtrlListView_DeleteAllItems($idListview) ;~ $iLV_Codici = _GUIListViewEx_Close($idListview) ConsoleWrite("_GUICtrlListView_DeleteAllItems" & @CRLF) IF $filtrato = 0 Then For $a=0 to UBound($TotaleEtichetteCodici)-1 ; Loop through the array to display the individual values. Local $aList1[UBound($TotaleEtichetteCodici)], $sText If IsArray($TotaleEtichetteCodici) Then $sText = $TotaleEtichetteCodici[$a][0] ConsoleWrite("sText non filtrato = " & $sText & @CRLF) $aList1[$a] = $sText GUICtrlCreateListViewItem($sText, $idListview) EndIf Next EndIf if $filtrato = 1 Then For $a=0 to UBound($aTempArray)-1 ; Loop through the array to display the individual values. Global $aList1[UBound($aTempArray)], $sText If IsArray($aTempArray) Then $sText = $aTempArray[$a][0] ConsoleWrite("sText = " & $sText & @CRLF) $aList1[$a] = $sText GUICtrlCreateListViewItem($sText, $idListview) EndIf Next EndIf $iLV_Codici = _GUIListViewEx_Close($idListview) $iLV_Codici = _GUIListViewEx_Init($idListview, $aList1, 0, 0, True, 128 + 256); 0, 0, True, 1 + 2 + 8, "0;2") EndFunc ;==>_filtraCodici