I am writing a class that has a list of strings as one of its
properties. I want to be able to run some code whenever that list of
strings is modified through the class property. Here is the
definition of the property 'JobSites'
Public Class SiteList
Private _JobSites As New List(Of String)
Public Property JobSites() As List(Of String)
Get
Return _JobSites
showSite()
End Get
Set(ByVal value As List(Of String))
_JobSites = value
showSite()
End Set
End Property
End Class
Whenever I add or remove a string from the JobSites list I want to be
able to process the results, for example
Dim Test as new SiteList
Test.JobSites.Add("Example 1") 'At this point, I want the object to
run some code internally
Do I override the List's Add method? Have not had any luck trying to
declare the list as withevents and then overriding the methods that
alter the list. Any suggestions?