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

CollectionEditor BUG

<I've reposted this here as it was slipping away over the horizon on the C# group

Hi all,

I've been writing an application that uses a class object (call it Element) that I need to expose to the user at runtime for editing. To do this, I've been using the PropertyGrid control. The Element object has a collection property that contains references to other Elements (its purpose is to allow the users to generate XML schemas at runtime, in which elements can be nested to arbitrary depth). The PropertyGrid control opens an instance of the CollectionEditor class when the user opens the collection property of a selected Element for editing. The CollectionEditor class displays in its right panel another PropertyGrid for editing the properties of the selected colection member, and in its left panel has a listbox containing the members of the collection. One useful feature is that the user can add a new instance of the collection type (the default is Object) by clicking an Add button. This generates a new instance and adds it to the collection (in a rather complicated way, as it turns out). To support this, I've written a strongly-typed collection class for Element objects, so that the CollectionEditor knows what type to generate, and what properties to display for editing

Here's the problem: When a user clicks "Add", a new instance of the collection type is added (which in this case also contains its own collection). If the user then goes to edit the collection property of the new instance, yet another Collection Editor pops up. The user can click "Add" in this window too, which will add a new child Element to the new Object's collection. In this way the user can "drill down", adding children to children, etc., with no apparent limit. The difficulty arises when the user decides to save, which involves clicking "OK" on the topmost CollectionEditor window, then on the one below it, etc... However, although the topmost one closes just fine, the ones below pop up a messagebox saying "Error: Object reference not set to an instance of an object." This is not a standard system unhandled-exception popup, but seems instead to be some custom message, probably generated in a "catch" block somewhere in the editor source code. I have exhaustively examined my own code, put breakpoints everywhere, made sure that Element constructors are being called at each level, etc., but have found no problem. The CollectionEditor seems to be doing alot of work behind the scenes over and above just adding/removing things from the existing collection, and the documentation of what it is doing seems to be nonexistent.

Sorry this was such a long-winded post, but it is a tricky thing to explain. Can anyone shed any light on this

Thanks, M


Jul 21 '05 #1
0 1329

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

Similar topics

2
by: m. pollack | last post by:
Hi all I've been using the PropertyGrid to allow the user to edit a class object at runtime. The class object contains a custom strongly-typed collection, and I have written a subclass of...
2
by: m. pollack | last post by:
Hi all I've been using the PropertyGrid to allow the user to edit a class object at runtime. The class object contains a custom strongly-typed collection, and I have written a subclass of...
0
by: juststarter | last post by:
Hello all, here is my problem. I am using a property grid control (in a vb.net 2003 project) in which two properties are exposed : "editorStyle" and "events". The first property is used to select...
0
by: Andreas | last post by:
Hi! I'm using a custom collection with custom items to be edited with a custom CollectionEditor. This set of functionality is to be a part of a plugin for a SharpDevelop-based application. The...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.