Delete button in a ListView

1

I have a problem with my delete button, that is, it works, but when I delete something from your ID, it does not automatically delete. I have to restart or add a new registry to delete it. Any suggestions?

Below is the snippet of the code and the interface of the delete button.

    
asked by anonymous 07.07.2015 / 17:43

1 answer

0

This is because removing an item from the database will not automatically be removed from the ListView array of items.

If the items are selected in the ListView simply add these lines in the click event of the remove button:

    For Each i As ListViewItem In ListView1.SelectedItems
        ListView1.Items.Remove(i)
    Next

This code will automatically remove the selected items in the ListView.

Another way to do this would be to delete all items from the ListView and then call the function you used to put all items in the ListView.

ListView1.Items.Clear()
ColocarItemsNaListView()
    
08.08.2015 / 20:31