473,320 Members | 1,884 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

CollectionBase.OnSetComplete Method?

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

Nov 22 '05 #1
0 880

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Steve M | last post by:
I have subclassed CollectionBase. I have also implemented GetEnumerator(). I have tried to set the DataSource of a DataGrid to an instance of my subclass. However, the items in the grid are not...
7
by: m. pollack | last post by:
Hi all, I've been using the CollectionBase class to implement a strongly-typed collection, but I have noticed that the RemoveAt method does not seem to call the "On" hook methods (OnRemove,...
0
by: Shannon Richards | last post by:
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...
1
by: alanrn | last post by:
I've implemented a number of strongly-typed collections that inherit from CollectionBase and recently noticed something that I don't fully understand. CollectionBase defines method RemoveAt(). ...
5
by: Eric Johannsen | last post by:
I have a simple object that inherits from CollectionBase and overrides the Count property: namespace MyTest { public class CollTest : System.Collections.CollectionBase { public override int...
1
by: Matthew Roberts | last post by:
Howdy Everyone, I am having trouble understanding the process of creating a type-safe collection by inheriting from the CollectionBase class. I have done it plenty of times, but now that I sit...
3
by: Shannon Richards | last post by:
Can anyone tell me what the CollectionBase.OnSetComplete() overridable method is supposed to be used for? MyCollectionClass(Index) = Object triggers this method but why does "setting" in a...
2
by: Samuel R. Neff | last post by:
What's the advantage of inheriting from CollectionBase as opposed to just implementing IList? It seems that it saves you from having to implement a few properties (Clear, CopyTo, Count,...
0
by: Ramiro Escobar via DotNetMonster.com | last post by:
I'm try to follow the .NET SDK Rockford Lotkha's example regarding a collection inherited from CollectionBase that binds to a Windows Forms Datagrid. My problem is that I cannot raise the...
1
by: graeme gorman | last post by:
Hi I have a class that inherits CollectionBase - now what I want is to be able to validate data when it is updated in the List (I need to make sure that certain values are not duplicates) so I...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.