deleting items from listbox with DEL
-
I've programmed a button, called 'Remove' to delete items, by counting the amount of selections, and than by a for-loop, doing listbox.remove, and when the loop is done, all selected items were deleted. But it just doesn't seem so userfriendly with this button. Does listbox have something simple that allows the delete-key the do the same as the remove-method? Or should I be thinking in terms of making an event for listbox, and check if the 'DEL'-key was pressed, and then execute the same code as with my button? Thanks in advance
-
I've programmed a button, called 'Remove' to delete items, by counting the amount of selections, and than by a for-loop, doing listbox.remove, and when the loop is done, all selected items were deleted. But it just doesn't seem so userfriendly with this button. Does listbox have something simple that allows the delete-key the do the same as the remove-method? Or should I be thinking in terms of making an event for listbox, and check if the 'DEL'-key was pressed, and then execute the same code as with my button? Thanks in advance
Hi, I would use ListBox.KeyDown event and a foreach loop over ListBox.SelectedItems to call ListBox.Remove :)
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google