473,800 Members | 2,741 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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. OnRemoveComplet e) 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 1765
I am not too familiar with PropertyGrid or the CollectionEdito r 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*******@disc ussions.microso ft.com>
| Sender: "m.pollack" <an*******@disc ussions.microso ft.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: AcPXLKORHVjUpaD CSL+76ScyCS52wQ ==
| X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.publi c.dotnet.genera l
| Path: cpmsftngxa07.ph x.gbl
| Xref: cpmsftngxa07.ph x.gbl microsoft.publi c.dotnet.genera l:120625
| NNTP-Posting-Host: tk2msftngxa08.p hx.gbl 10.40.1.160
| X-Tomcat-NG: microsoft.publi c.dotnet.genera l
|
| 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. OnRemoveComplet e) 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
CollectionEdito r.DestroyInstan ce 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
CollectionEdito r 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 CollectionEdito r 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*******@disc ussions.microso ft.com>
| Sender: "m.pollack" <an*******@disc ussions.microso ft.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: AcPXLKORHVjUpaD CSL+76ScyCS52wQ ==
| X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.publi c.dotnet.genera l
| Path: cpmsftngxa07.ph x.gbl
| Xref: cpmsftngxa07.ph x.gbl microsoft.publi c.dotnet.genera l:120625| NNTP-Posting-Host: tk2msftngxa08.p hx.gbl 10.40.1.160
| X-Tomcat-NG: microsoft.publi c.dotnet.genera l
|
| 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. OnRemoveComplet e) 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
1874
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, OnRemoveComplete). The Add method works fine, though! I need these to work -- I am exposing the collection to the user through a PropertyGrid control, and the user can add/remove collection elements with the (apparently undocumented) Object...
1
2337
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 property, using a class derived from CollectionBase, to the user via the PropertyGrid control's popup Collection Editor. I need to know when the user has added or removed
1
2111
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(). However, CollectionBase implements IList which also defines method RemoveAt(). In my collection when I code my own RemoveAt() method, the compiler issued a warning indicating that my RemoveAt() must be defined with a "new" keyword. So, to keep...
9
1584
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 override inherited member 'System.Collections.CollectionBase.RemoveAt(int)' because it is not marked virtual, abstract, or override is this some kind of bug or what?
1
2905
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 related to an invoice -InvoiceCollection: Inherited from Collectionbase class and holds Invoice objects The InvoiceCollection class is as follows:
2
6967
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, GetEnumerator, and RemoveAt) but the way it implements all the other things you need to override seems overkill and counters the advantage of having an extensible base class. For example, the documentation example implementation of Remove: Public...
2
346
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 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
2
2144
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
1154
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 of the class ElementClass.cs. When I click the Button2 an exception occurs….index out of range….This happens because of the fact that the class I added by clicking Button1 is lost when I click the Button2…This problem is associated with Postback of...
0
10501
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10273
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10250
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10032
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7574
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.