Delete button on a Listview

Asked

Viewed 346 times

1

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

Below is the code snippet and the delete button interface.

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

1 answer

1

This is because removing an item from the database will not be altomatically removed from the Listview item array.

If the items are selected in Listview just add these lines in the remove button click event:

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

This code will automatically remove the selected items in Listview.

Another way to do this would be to delete all Listview items and then call the function you used to place all items in Listview.

ListView1.Items.Clear()
ColocarItemsNaListView()

Browser other questions tagged

You are not signed in. Login or sign up in order to post.