Pages

Total Pageviews

Add This

Friday, May 6, 2011

Remove Selected Item from Listview

Create a form like on the picture bellow:
Write the code into the Button "Remove selected item"

ListView1.Items.RemoveAt(ListView1.SelectedItems(0).Index)

2 comments:

  1. Adding Items to ListView from TextBoxes

    Private Sub TextBox2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox2.KeyDown
    If e.KeyCode = Keys.Enter Then
    ListView1.Items.Add(TextBox1.Text)
    ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(TextBox2.Text)
    End if
    End Sub

    Remove Multiple Selected Items
    For Each LVItem As ListViewItem In TransListView.SelectedItems
    LVItem.Remove()
    Next

    i think this is more clear!

    ReplyDelete