Sign in to follow this  
Followers 0
cheese

ListView Delete All Items [solved]

3 posts in this topic

#1 ·  Posted (edited)

Hi!

Why it don't works?

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
$Gui = GUICreate("_GUICtrlListView_DeleteAllItems",300,200)
$btnAdd = GUICtrlCreateButton("Add",2,2,120,23)
$btnDel = GUICtrlCreateButton("Delete",134,2,120,23)
$hListView = GUICtrlCreateListView("Items",2,27,296,171)
GUISetState()
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $btnAdd
            For $i = 1 To 5
            _GUICtrlListView_AddItem($hListView,$i)
            GUICtrlSetData($btnDel,"Delete")
            Next
        Case $btnDel
            _GUICtrlListView_DeleteAllItems($hListView)
            GUICtrlSetData($btnDel,"Why It Not Work?")
    EndSwitch
WEnd
GUIDelete()
Edited by cheese

Share this post


Link to post
Share on other sites



I'm not sure why it doesn't work. This does: (just added a GUICtrlGetHandle around the $hListview)

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
$Gui = GUICreate("_GUICtrlListView_DeleteAllItems",300,200)
$btnAdd = GUICtrlCreateButton("Add",2,2,120,23)
$btnDel = GUICtrlCreateButton("Delete",134,2,120,23)
$hListView = GUICtrlCreateListView("Items",2,27,296,171)
GUISetState()
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $btnAdd
            For $i = 1 To 5
            _GUICtrlListView_AddItem($hListView,$i)
            GUICtrlSetData($btnDel,"Delete")
            Next
        Case $btnDel
            _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($hListView))
            GUICtrlSetData($btnDel,"Why It Not Work?")
    EndSwitch
WEnd
GUIDelete()

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

Achilles, thank you. Now it work! :)

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