Add, Remove and Clear Items from ListView Control in VB.NET

2011-02-14


Private Sub cmdAddItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAddItem.Click
      lvItemList.Items.Add(txtAddItem.Text & "")
End Sub


Private Sub cmdRemoveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRemoveItem.Click
 For Each lvItem As ListViewItem In lvItemList.SelectedItems
      lvItem.Remove()
 Next
End Sub

Private Sub cmdClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdClear.Click
      lvItemList.Items.Clear()
End Sub