473,574 Members | 2,726 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Issue with CollectionEdito r handling multiple sub-types

Hi all,

I am having an issue with a custom CollectionEdito r. My scenario is as
follows:
I have a base type TypeA. I also have a TypeACollection . The TypeACollection
has an Editor attribute of TypeACollection Editor. This collection editor
derives from the framework CollectionEdito r, passing TypeACollection in the
constructor to indicate which type it deals with.

I then have TypeB, which derives from TypeA, but adds specific
functionality. I have then created a TypeBCollection Editor, which handles
editing TypeB instances.
I then have 2 properties on an object, both of TypeACollection , as this can
contain both TypeA and TypeB instances.
Only 1 instance of the collection will ever deal with the 1 type. I.e. no
collection will ever have to contain both TypeA and TypeB objects.
I therefore specify an attribute on the PROPERTY which will contain TypeB
objects that the editor is TypeBCollection Editor, to override the default
type based value on the TypeACollection of TypeACollection Editor.

My TypeBCollection Editor derives from TypeACollection Editor, and I was
planning on simply overriding a couple of methods such as CreateNewItemTy pes
and CreateInstance to return TypeB specific details.
This all looked fine - when I clicked "Add" the correct type was being
created based on which property I was editing. However, when I close the
collection editor form and the component I am editing, and then re-open the
component in VStudio, and then edit the collection which should contain
TypeB objects, the form is created, with the previously configured info, but
the items are created as TypeA objects, NOT TypeB. The only method that
seems to be called before the form loads and displays is GetItems, but by
then the TypeA objects have already been created and cannot be cast to
TypeB, as TypeB is more specific.

Has anyone got any ideas what I am doing wrong, or exactly which methods I
need to override? All CollectionEdito r methods I override are called too
late, and the CollectionEdito r form has already displayed with incorrect
types. I think it is something to do with the CollectionEdito r looking at
the indexer of the collection and picking that type?

Thanks heaps,

Bardo.
Feb 2 '07 #1
0 1131

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

Similar topics

0
1347
by: m. pollack | last post by:
<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...
2
2093
by: Eric Newton | last post by:
VB's more declarative nature of handling events is golden. I'm hoping C# will acquire this type of deal, in addition to the anonymous delegates. could do same as vb (actually would be easier to parse then vb due to braces) whereas you look for Handles keyword after method sig, but before opening brace of the method. compiler would...
0
1593
by: m. pollack | last post by:
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...
0
1216
by: m. pollack | last post by:
<I've reposted this as it was slipping away over the horizon 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...
13
2217
by: Lorne Smith | last post by:
Hi, First, sorry for the crosspost, but it seemed appropriate... :) I've come accross what I consider to be a bug, but I don't know if it's already known or not. (VS .Net 2003 Pro - VB.Net) Whilst playing with inherited forms, I created a simple base form containing a single button. I set this buttons' Click event to be public...
0
806
by: Chris McKenzie | last post by:
According to http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcomponentmodeldesigncollectioneditorclasscreatecollectionformtopic.asp I can inherit from CollectionEditor.CollectionForm. However, when I try to inherit from the class, I get an error: NodeCollectionEditor.vb(50):...
7
2611
by: Simon Verona | last post by:
I have a problem in my application which I believe is due to open handles.. . The symptom that users report is that after they have been using the application for a while, it will randomly just crash with an exception report (I've not got the details of the error, but I'm working on that now!). I'm trying to reproduce the circumstances by...
0
1555
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 one of a series of web controls. The second one opens a collectioneditor which also exposes two properties : "event" and "command". The "event"...
0
1582
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 strange thing now is that my derived CollectionEditor's SetItems method is called when testing the collection editing within a small test...
0
974
by: --== Alain ==-- | last post by:
Hi I've create a C++ managed Class as : *.h file -------- #pragma once #include "afxcmn.h" using namespace System::Design; using namespace System::Drawing::Design; using namespace System::ComponentModel;
0
7747
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8262
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...
1
7843
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...
0
8129
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...
0
6498
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...
0
5331
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3768
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...
0
3785
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2262
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.