473,382 Members | 1,329 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,382 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

Jul 21 '05 #1
0 989

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,...
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...
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...
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: 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...
1
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: 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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.