Sign in to follow this  
Followers 0
leegold

Can Mouse Select Row in ListBox and Delete?

4 posts in this topic

Hi,

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...

Thanks

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

$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 :)

Edit:

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

Share this post


Link to post
Share on other sites

$List1 = GUICtrlCreateList("", 168, 64, 121, 97, $LBS_EXTENDEDSEL)

If you want to select multiple entries.

Share this post


Link to post
Share on other sites

Thank you. I will give it a try. Thanks again!

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