Jump to content

Can Mouse Select Row in ListBox and Delete?

Recommended Posts


Googled and searched - apologize if this had been asked before.

Say we create a list box: $mylist = GUICtrlCreateList(....), we then populate the list box with a few rows. It's well documented and easy to clear the entire list. But the action I'm looking for is:  the user selects a row(s) ...ie a row gets highlighted (a mouse click eg. does that right now). Is there a way to delete just that row? Either a button or a mouse right click-> delete?

Is is possible to select multiple rows and do the same?

I don't want to allow edits a row's text (that's why I thought to use a List Box), but I need added rows to be deletable and of course I assume the List Box's "internal array" would be updated/refreshed to reflect adds and deletes...


Link to post
Share on other sites

$mylist = your GUICtrlCreateList

here's a working example:

_GUICtrlListBox_DeleteString($mylist, _GUICtrlListBox_GetCurSel($mylist))

Note the two functions used.

_GUICtrlListBox_GetCurSel = http://www.autoitscript.com/autoit3/docs/libfunctions/_GUICtrlListBox_GetCurSel.htm

_GUICtrlListBox_DeleteString = http://www.autoitscript.com/autoit3/docs/libfunctions/_GUICtrlListBox_DeleteString.htm

Note: You should already have #include <GUIConstantsEx.au3> , but you will also need #include <GuiListBox.au3>

Have a good day :)


Just noticed you stated you also wanted to be able to edit the text.

_GUICtrlListBox_ReplaceString = http://www.autoitscript.com/autoit3/docs/libfunctions/_GUICtrlListBox_ReplaceString.htm

Should do the trick.

Edited by Andreu
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...