Jump to content

How do I delete an item from a ListView


Recommended Posts

GuiCtrlDelete ( $ListViewItem )

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Link to comment
Share on other sites

  • 2 weeks later...

Hi!

I also have some problems deleting a selected ListViewItem. First I tried this:

GUICtrlDelete(GUICtrlRead($MyListView_Handler))

$MyListView_Handler is the handler of the ListViewControl

GUICtrlRead( ) should return the handler of selected ListViewItem

GUICtrlDelete( ) should delete the Item

It didn't work :-(

I already tried the tip from:

http://www.autoitscript.com/forum/index.ph...wtopic=7026&hl=

my resulting code:

$LVM_DELETEITEM = 0x1008
$i = ControlListView ( "", "", $MyListView_Handler, "GetSelected" )
GuiCtrlSendMsg($MyListView_Handler, $LVM_DELETEITEM,$i,0)

This didn't work either, the selected ListViewItems where still there.

Do I have to 'update' (eg GUICtrlSetData) the ListView?

Can anyone help?

Thanks

Link to comment
Share on other sites

Hi!

I also have some problems deleting a selected ListViewItem. First I tried this:

GUICtrlDelete(GUICtrlRead($MyListView_Handler))

$LVM_DELETEITEM = 0x1008

$i = ControlListView ( "", "", $MyListView_Handler, "GetSelected" )

<{POST_SNAPBACK}>

You are looking for a listview in a gui with a blank title ?
$i = ControlListView ( "WinTitleGoesHere", "WinTextGoesHere", $MyListView_Handler, "GetSelected" )
Link to comment
Share on other sites

Thanks for your reply, but ControlListView accesses the correct ListView and returns a correct value $i (starting with "0" if the first item was selected), @error is "0" too.

GuiCtrlSendMsg returned always "0" and no @error.

But finally I found the reason of the trouble:

Unfortunately $i was a String, so I had to convert the return using Number() before GuiCtrlSendMsg was able to work with it

$i = Number(ControlListView ( "", "", $MyListView_Handler, "GetSelected" ))
GuiCtrlSendMsg($MyListView_Handler, $LVM_DELETEITEM,$i,0)

It's so easy... ;-)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...