473,406 Members | 2,707 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,406 software developers and data experts.

Issue with CollectionEditor handling multiple sub-types

Hi all,

I am having an issue with a custom CollectionEditor. My scenario is as
follows:
I have a base type TypeA. I also have a TypeACollection. The TypeACollection
has an Editor attribute of TypeACollectionEditor. This collection editor
derives from the framework CollectionEditor, 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 TypeBCollectionEditor, 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 TypeBCollectionEditor, to override the default
type based value on the TypeACollection of TypeACollectionEditor.

My TypeBCollectionEditor derives from TypeACollectionEditor, and I was
planning on simply overriding a couple of methods such as CreateNewItemTypes
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 CollectionEditor methods I override are called too
late, and the CollectionEditor form has already displayed with incorrect
types. I think it is something to do with the CollectionEditor looking at
the indexer of the collection and picking that type?

Thanks heaps,

Bardo.
Feb 2 '07 #1
0 1117

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

Similar topics

0
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...
2
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...
0
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....
0
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...
13
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) ...
0
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...
7
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...
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: --== 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...
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: 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
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,...
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,...
0
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...

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.