Jump to content
Sign in to follow this  
Noobster24

Clear a ListView

Recommended Posts

Noobster24

Hi,

;more code

$listview = GUICtrlCreateListView ("Naam|ID",125,5,500,345,-1,BitOR($LVS_EX_REGIONAL, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))
_GUICtrlListViewSetColumnWidth($listview,0,390)
_GUICtrlListViewSetColumnWidth($listview,1,106)

$B_DESCENDING = _GUICtrlListViewGetSubItemsCount($listview)
If IsArray($Links) And IsArray($Names) Then
            For $i = 0 To UBound($Links) - 1
        GUICtrlCreateListViewItem($Names[$i] & '|' & $Links[$i],$listview)
            Next
        EndIf
;more code

This is a part of my script to make a ListView to put some data in. I created a button named Clear:

;more code
$about = GuiCtrlCreateButton("About", 10, 260, 60, 30)
$afsluiten = GuiCtrlCreateButton("Afsluiten", 10, 310, 60, 30)
$zoek = GuiCtrlCreateButton("Zoek!", 10, 160, 60, 30)
$clear = GuiCtrlCreateButton("Clear", 10, 210, 60, 30)
;morecode

And if the button is clicked, i want to clear the listview, so that is empty again...

I searched in the beta help, but i can only find this function:

_GUICtrlListClear

But that function isn't working, i use it like this:

;more code
GuiSetState()
While 1
$msg = GuiGetMsg()
If $msg = $about Then MsgBox(64,"About & Credits","This is a special one to W.C. Van Bart-Kuiper!")
If $msg = -3 OR $msg = $afsluiten Then ExitLoop
If $msg = $zoek Then _Check($sq)
If $msg = $clear Then _GUICtrlListClear($listview)
If $msg = $listview Then _GUICtrlListViewSort($listview, $B_DESCENDING, GUICtrlGetState($listview))
WEnd

What's the function to clear the data from $listview?


Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.

Share this post


Link to post
Share on other sites
Noobster24

_GUICtrlListViewDeleteAllItems

So easy, yet so hard to find :D

Thank you! :D


Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.

Share this post


Link to post
Share on other sites
sykes

We need a new function:

_GuiCtrlFindWhatImLookingFor

:D


We have enough youth. How about a fountain of SMART?

Share this post


Link to post
Share on other sites
SmOke_N

VERY NICE! :D any progress on the _IHaveAProblemButYouHaveToGuessWhatMyCodeIs() udf? :D

_IHaveAProblemButYouHaveToGuessWhatMyCodeIs()

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
SmOke_N

:D

Edit:

That will be my new answer instead of a long speech.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Zachlr

I have #Include <GuiListView.au3>, but I still get ERROR: _GUICtrlListViewDeleteAllItems(): undefined function. I am using version 3.3.0.0.

Share this post


Link to post
Share on other sites
Mat

I have #Include <GuiListView.au3>, but I still get ERROR: _GUICtrlListViewDeleteAllItems(): undefined function. I am using version 3.3.0.0.

yep its now

_GUICtrlListView_DeleteAllItems

;================================================================================================
; depricated functions will no longer work
; ===================================================================================================
; #OLD_FUNCTIONS#===============================================================
; Old Function/Name                      ; --> New Function/Name/Replacement(s)
; ===========================================================================
;_GUICtrlListViewCopyItems                ; --> _GUICtrlListView_CopyItems
;_GUICtrlListViewDeleteAllItems           ; --> _GUICtrlListView_DeleteAllItems
Edited by mdiesel

Share this post


Link to post
Share on other sites
CodyBarrett

HA! :D thats funny! lol i wish telepathy was possible :o then we would know what everyone wanted!

Share this post


Link to post
Share on other sites
Mat

HA! :D thats funny! lol i wish telepathy was possible :o then we would know what everyone wanted!

still doesn't mean we'd be able to answer it though.

Share this post


Link to post
Share on other sites
CodyBarrett

no but then we wouldnt have to waste time asking

OH yeah you have any code to start?

or

RIGHT! now what are you using this for? hmm? a trogan? thats naughty!

sorry man this is a little off topic my BAD :D

Share this post


Link to post
Share on other sites
Zachlr

yep its now

_GUICtrlListView_DeleteAllItems

;================================================================================================
; depricated functions will no longer work
; ===================================================================================================
; #OLD_FUNCTIONS#===============================================================
; Old Function/Name                      ; --> New Function/Name/Replacement(s)
; ===========================================================================
;_GUICtrlListViewCopyItems                ; --> _GUICtrlListView_CopyItems
;_GUICtrlListViewDeleteAllItems           ; --> _GUICtrlListView_DeleteAllItems
Ah! Thank you!

Share this post


Link to post
Share on other sites
Cusem

_GUICtrlListView_DeleteAllItems returns FALSE in my script and I don't know why.

I have a globally declared listview

Local $iExWindowStyle = BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE)
Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)
$LV_Main = GUICtrlCreateListView("", 150, 100, 860, 430, $WS_BORDER)
_GUICtrlListView_SetExtendedListViewStyle($LV_Main, $iExListViewStyle)

It is populated by a function that does:

If _GUICtrlListView_InsertColumn($LV_Main, 0, "Column1", 70) = -1 Then $rr += 1
    If _GUICtrlListView_InsertColumn($LV_Main, 1, "Column2", 80) = -1 Then $rr += 1
    If _GUICtrlListView_InsertColumn($LV_Main, 2, "Column3", 70) = -1 Then $rr += 1
    If _GUICtrlListView_InsertColumn($LV_Main, 3, "Column4", 70) = -1 Then $rr += 1
    If _GUICtrlListView_InsertColumn($LV_Main, 4, "Column5", 90) = -1 Then $rr += 1
    If _GUICtrlListView_InsertColumn($LV_Main, 5, "Column6", 100) = -1 Then $rr += 1
    If _GUICtrlListView_InsertColumn($LV_Main, 6, "Column7", 200) = -1 Then $rr += 1
    If _GUICtrlListView_InsertColumn($LV_Main, 7, "Column8", 40) = -1 Then $rr += 1
    If _GUICtrlListView_InsertColumn($LV_Main, 8, "Column9", 50) = -1 Then $rr += 1
    If _GUICtrlListView_InsertColumn($LV_Main, 9, "Column10", 45 )= -1 Then $rr += 1
    If _GUICtrlListView_InsertColumn($LV_Main, 10, "Column11", 40) = -1 Then $rr += 1
Dim $aDBMainWork[195][12]
_GUICtrlListView_AddArray($LV_Main, $aDBMainWork)

Called from another function

MsgBox(0, "tesT", _GUICtrlListView_DeleteAllItems($LV_Main))

returns False

_GUICtrlListView_RegisterSortCallBack($LV_Main)

Was the only thing I can think about what was causing the error, so I added

_GUICtrlListView_UnRegisterSortCallBack($LV_Main)
MsgBox(0, "tesT", _GUICtrlListView_DeleteAllItems($LV_Main))

But with no succes.

Anybody got any idea what is going wrong? I'm on 3.3.0.0 on XP SP2 x64

Share this post


Link to post
Share on other sites
Cusem

Solved it.

I had to use _GUICtrlListView_DeleteAllItems(CtrlGetHandle($LV_Main)) instead of _GUICtrlListView_DeleteAllItems($LV_Main).

It is however pretty unclear to me when to use CtrlGetHandle($x) instead of just $x. If anybody could explain this?

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  

×