Hello All: Can anyone tell what exactly this method is supposed to be used
for? I have a class that derives from CollectionBase. This class overrides
the OnSetComplete() method to raise an event when a child object changes?
example: The overridden OnSetComplete() method in the collection class
Protected Overrides Sub OnSetComplete(ByVal index As Integer, ByVal oldValue
As Object, ByVal newValue As Object)
RaiseEvent Changed ()
End Sub
-----------------------------------------------------------------------------------------
example: Class contained int he collection tells the collection that it's
been modified...
Public Property Name() As String
Get
Return ms_Name
End Get
Set(ByVal Value As String)
ms_Name = Value
If (Not mo_Parent Is Nothing) Then
Dim li_Idx As Integer = mo_Parent.IndexOf(Me)
mo_Parent(li_Idx) = Me
End If
End Set
End Property
The problem is when I loop through the collection of these objects changing
properties etc I get an error:
An unhandled exception of type 'System.InvalidOperationException' occurred
in mscorlib.dll
Additional information: Collection was modified; enumeration operation may
not execute.
Can anyone explain this to me? I believe it's because mo_Parent(li_Idx) =
Me
actually sets the current enumerator position in the collection class and
you cannot do that inside a loop?
Thanx,
Shannon Richards
BBA, AIT, MCP