Once we've added ListItems to the ListView, the next logical step to look at is removing them. Not surprisingly, removing a ListItem is a simple task, achieved by calling the Remove method of the ListItems collection.
Again, since we'll also be removing items with API calls, timing the removal will help quantitatively compare the two methods. Listing 4 shows the Click event handler for cmdCOMDelete.
Private Sub cmdCOMDelete_Click()
Dim lTime As Long
' get current tick count
lTime = GetTickCount
' delete the selected item with object model calls
lvwMain.SetFocus
lvwMain.ListItems.Remove
lvwMain.SelectedItem.Index
' determine ET and display it
lblET.Caption = CStr(GetTickCount - lTime)
End Sub
There is a lot more functionality exposed by the ListView COM object's methods and properties, but they are, for the most part, pretty intuitive and easy to get a handle on. Use the Object Browser (press F2 in the eVB IDE) to explore the rest of the object model and play around to familiarize yourself with the control's capabilities.