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

TypeConverter problems.

Hi all

I created Collection + CollectionItem classes and a TypeConverter in order
to persist the items in the collection. I then added descendants of these
classes (ImageCollection, ImageItem).

The persistence etc works fine until I add a property to the descended
class, and then the created items do not appear in the collection editor
list. Anyone have any ideas?
internal class CollectionItemConverter: TypeConverter
{
public override Boolean CanConvertTo(ITypeDescriptorContext context, Type
destinationType)
{
if (destinationType == typeof(InstanceDescriptor))
return true;
return base.CanConvertTo(context, destinationType);
}

public override object ConvertTo(ITypeDescriptorContext context,
System.Globalization.CultureInfo culture, object value, Type
destinationType)
{
if (destinationType == typeof(InstanceDescriptor))
{
System.Reflection.ConstructorInfo ci =
value.GetType().GetConstructor(System.Type.EmptyTy pes);
return new InstanceDescriptor(ci, null, false);
}
return base.ConvertTo(context, culture, value, destinationType);
}
}

--
Pete
=============
Read or write technical articles
http://www.HowToDoThings.com

Audio compression components, FastStrings library, DIB controls
http://www.DroopyEyes.com

-There are 10 types of people in the world, those who understand binary, and
those who don't

Jul 19 '05 #1
0 1870

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

Similar topics

2
by: kw | last post by:
I'm getting different behavior from what I would expect and was hoping someone could clue me in. At run time I need to examine a property of an object for a custom TypeConverter, then use that...
1
by: Sky Sigal | last post by:
(PS: Cross post from microsoft.pulic.dotnet.framework.aspnet.webcontrols) I've been looking lately for a way to keep the Properties panel for Controls 'clean'... My goal is to keep similar...
5
by: ljlevend | last post by:
Is there a TypeConverter that converts Doubles to percent values in a PropertyGrid? The Windows.Forms.Form.Opacity property seems to use the TypeConverter that I want. Thank you, Lance
0
by: Alex Clark | last post by:
Hi all, Apologies for the cross-post but I can't determine if this is a VS .NET problem or a VB.NET language issue. I'm using .NET 1.1 SP1, VS 2003 EA, VB.NET. I'm coding a custom component...
0
by: Peter Morris | last post by:
Hi all I created Collection + CollectionItem classes and a TypeConverter in order to persist the items in the collection. I then added descendants of these classes (ImageCollection, ImageItem)....
4
by: Kent Boogaart | last post by:
*tried this already on the buildingcontrols newsgroup but didn't get a response* Hi, As far as I can tell, it is not possible to use the TypeConverter infrastructure with generic types. Say...
11
by: Rolf Welskes | last post by:
Hello, the problem seems to be complex and is in all developments of web-controls which uses own TypeConverter. For this I have here a simple demo-program of the problem: The Control-code: A...
1
by: --== Alain ==-- | last post by:
Hi, I 'm facing an interesting issue regarding a property and its TypeConverter. When i do not attach a TypeConverter to this property, all custom properties of my custom control are displayed...
6
by: Larry Smith | last post by:
Hi there, Can anyone provide any insight on why MSFT introduced "TypeConverter.GetProperties()". There are two classes for dealing with metadata in .NET, 'Type" and "TypeDescriptor". Each has a...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.