Guys need help.. I have button that adds element in array and displays the item that is added in array in the listview, And also i have button that deletes it but it's not working.

Here's the code:

Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click
        Dim i As Integer
        Dim new_array As New List(Of String)(movieArray)
        With ListView1
            If Not .SelectedItems.Count >= 0 Then
                ListView1.SelectedItems(0).Remove()
                new_array.RemoveAt(movieArray(i))
            End If
        End With
    End Sub

movieArray - Where the items stored.

Ckeck the i value when ur deleting. i think it will be allways zero. as u have declared dim i as integer but never assigned the value to it. Problably if u remove first item it is working.

Sir i was able to delete an element from an array now, but my problem is it's deleting from array 0 to upper bound of the array, not the selected item from the listview.

Here's the updated code.

For i = N To UBound(movieArray) - 1
                movieArray(i) = movieArray(i + 1)
            Next i
            ReDim Preserve movieArray(UBound(movieArray) - 1)

Thanks in advance.

What is N here? is it holding the upper bound of array?
Get the index of selected item in ur array and use removeat and pass the index.

your "N" hold only the upper value.
Give the Increment value to the "N" as selected value of listview.
Then It will work.

This question has already been answered. Start a new discussion instead.