CollectionBase RemoveAt bug?

M

m.pollack

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
 
R

Ryan Byington

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" <[email protected]>
| Sender: "m.pollack" <[email protected]>
| Subject: CollectionBase RemoveAt bug?
| Date: Fri, 9 Jan 2004 19:48:41 -0800
| Lines: 21
| Message-ID: <[email protected]>
| 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
|
 
M

m. pollack

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 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top