Public Class Recipients Inherits CollectionBase Public Sub New() 'var Dim recipient As Recipient Try recipient = New Recipient("Mike", "1234", "Mike Inc.", "1234 5th St.", "Jesup", "IA", 50648) innerlist.Add(recipient) recipient = New Recipient("Joe", "4321", "Joe Inc.", "4321 1st St.", "Urbana", "IA", "55555") innerlist.Add(recipient) recipient = New Recipient("Herky", "5555", "Herky's Hawkeyes", "5555 5th St", "Iowa City", "IA", "54334") innerList.Add(recipient) Catch ex As Exception Throw ex End Try End Sub Public Sub Add(ByVal entry As Recipient) InnerList.Add(entry) End Sub Public Sub Remove(ByVal index As Integer) If index < 0 Or index > Me.Count - 1 Then Throw New IndexOutOfRangeException Else InnerList.RemoveAt(index) End If End Sub Default Public Property Item(ByVal index As Integer) As Recipient Get Return CType(InnerList.Item(index), Recipient) End Get Set(ByVal Value As Recipient) InnerList.Item(index) = Value End Set End Property End Class
Dim searchColl As Recipients searchColl = New Recipients DataGrid1.DataSource = searchColl searchColl.Add(New Recipient("Mark", "8493", "asdf", "8848 1 St.", "Clear Lake", "IA", "50436"))