473,396 Members | 1,764 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,396 software developers and data experts.

CollectionBase RemoveAt bug?

Hi all,

I have an application which uses a class object that
contains a collection. In order to use the PropertyGrid
control to expose properties to the user at runtime, I
created a strongly-typed collection class based on
CollectionBase. However, when I use the PropertyGrid to
remove objects from the collection at runtime via the
popup Object Collection Editor, it appears that the "On*"
(CollectionBase.OnRemove and
CollectionBase.OnRemoveComplete) hook methods in the
collection class aren't being called. The Insert hook
(CollectionBase.OnInsert) works fine, though. I need to
get this working, because if the user removes objects from
the collection I have housekeeping to do. Is this a bug?
It seems to be -- I saw one reference to the problem here:

http://lists.ximian.com/archives/public/mono-list/2001-
November/001978.html

Any thoughts? thanks... MP
Jul 21 '05 #1
2 1736
I am not too familiar with PropertyGrid or the CollectionEditor but it
appears that in v1.0 or v1.1 we do call the on methods as long as the index
is valid and OnValidate does not throw.

Let me know if you are still having problems and maybe post a simple repro
for the problem, and the version of the runtime you are using.

Ryan Byington [MS]

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
--------------------
| Content-Class: urn:content-classes:message
| From: "m.pollack" <an*******@discussions.microsoft.com>
| Sender: "m.pollack" <an*******@discussions.microsoft.com>
| Subject: CollectionBase RemoveAt bug?
| Date: Fri, 9 Jan 2004 19:48:41 -0800
| Lines: 21
| Message-ID: <00****************************@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcPXLKORHVjUpaDCSL+76ScyCS52wQ==
| X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.dotnet.general
| Path: cpmsftngxa07.phx.gbl
| Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.general:120625
| NNTP-Posting-Host: tk2msftngxa08.phx.gbl 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| Hi all,
|
| I have an application which uses a class object that
| contains a collection. In order to use the PropertyGrid
| control to expose properties to the user at runtime, I
| created a strongly-typed collection class based on
| CollectionBase. However, when I use the PropertyGrid to
| remove objects from the collection at runtime via the
| popup Object Collection Editor, it appears that the "On*"
| (CollectionBase.OnRemove and
| CollectionBase.OnRemoveComplete) hook methods in the
| collection class aren't being called. The Insert hook
| (CollectionBase.OnInsert) works fine, though. I need to
| get this working, because if the user removes objects from
| the collection I have housekeeping to do. Is this a bug?
| It seems to be -- I saw one reference to the problem here:
|
| http://lists.ximian.com/archives/public/mono-list/2001-
| November/001978.html
|
| Any thoughts? thanks... MP
|

Jul 21 '05 #2
Thanks Ryan,

I've done quite a bit of research since this post, with
the help of the newsgroup's readers, and it seems that the
Collection Editor bypasses the collection class's Remove
methods when removing an item. Rather, the
CollectionEditor.DestroyInstance method seems to create a
brand-new collection instance, minus the deleted member. I
was able to solve my problem by subclassing the Collection
Editor and setting the editor attribute of my custom
collection class to point to the subclass. In the subclass
I was able to get hold of the instance of the object being
deleted by overriding the DestroyInstance method.

It would be GREAT if the documentation for the
CollectionEditor class could go into more detail about how
it does its work!

Thanks, Malcolm Pollack

-----Original Message-----
I am not too familiar with PropertyGrid or the CollectionEditor but itappears that in v1.0 or v1.1 we do call the on methods as long as the indexis valid and OnValidate does not throw.

Let me know if you are still having problems and maybe post a simple reprofor the problem, and the version of the runtime you are using.
Ryan Byington [MS]

This posting is provided "AS IS" with no warranties, and confers no rights.Use of included script samples are subject to the terms specified athttp://www.microsoft.com/info/cpyright.htm
--------------------
| Content-Class: urn:content-classes:message
| From: "m.pollack" <an*******@discussions.microsoft.com>
| Sender: "m.pollack" <an*******@discussions.microsoft.com>| Subject: CollectionBase RemoveAt bug?
| Date: Fri, 9 Jan 2004 19:48:41 -0800
| Lines: 21
| Message-ID: <00****************************@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcPXLKORHVjUpaDCSL+76ScyCS52wQ==
| X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.dotnet.general
| Path: cpmsftngxa07.phx.gbl
| Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.general:120625| NNTP-Posting-Host: tk2msftngxa08.phx.gbl 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| Hi all,
|
| I have an application which uses a class object that
| contains a collection. In order to use the PropertyGrid
| control to expose properties to the user at runtime, I
| created a strongly-typed collection class based on
| CollectionBase. However, when I use the PropertyGrid to
| remove objects from the collection at runtime via the
| popup Object Collection Editor, it appears that the "On*"| (CollectionBase.OnRemove and
| CollectionBase.OnRemoveComplete) hook methods in the
| collection class aren't being called. The Insert hook
| (CollectionBase.OnInsert) works fine, though. I need to| get this working, because if the user removes objects from| the collection I have housekeeping to do. Is this a bug?| It seems to be -- I saw one reference to the problem here:|
| http://lists.ximian.com/archives/public/mono-list/2001-
| November/001978.html
|
| Any thoughts? thanks... MP
|

.

Jul 21 '05 #3

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

Similar topics

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: m. pollack | last post by:
Hi all, I'm still trying to get to the bottom of the problem I am having with the CollectionBase class and the Object Collection Editor. Briefly put, I am exposing a strongly-typed collection...
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(). ...
9
by: SharpCoderMP | last post by:
hi, does anyone know something about this: ..net documentation says that CollectionBase.RemoveAt(int index) is virtual method, but when i try to override it i get compiler error: cannot...
1
by: Kyle Novak | last post by:
I have a question about strongly typed objects when looping through a collection based on the CollectionBase object and using a For..Each loop. I have 2 objects: -Invoice: Holds all properties...
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,...
2
by: m.pollack | last post by:
Hi all, I have an application which uses a class object that contains a collection. In order to use the PropertyGrid control to expose properties to the user at runtime, I created a...
2
by: Juan Martinez | last post by:
Hello!! I have created my own collection : public class MyCollection { private Color color1 = Color.White; private Color color2 = Color.Black;
0
by: LIJO CHEERAN | last post by:
Hello friends I am trying to study about CollectionBase. I have inherited CollectionBase in the class TheCollection.cs. I am using the “TheCollection. in an aspx page to store objects...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.