posts - 78, comments - 79, trackbacks - 84

My Links

News

View Anthony Trudeau's profile on LinkedIn

Add to Technorati Favorites

Article Categories

Archives

Post Categories

Other Links

Localizing display properties in the PropertyGrid

So, localizing display properties in the PropertyGrid has been done before.  Probably ten different ways.  However, until the .NET Framework 2.0 it required some messy implementation in the concrete class.  Version 2.0 adds the TypeDescriptionProvider which can be tied to a particular class using the TypeDescriptionProviderAttribute.  The attribute accepts a type that inherits the TypeDescriptionProvider base class.

The rest of the article can be found at: http://geekswithblogs.net/tonyt/articles/70280.aspx

Print | posted on Friday, December 30, 2005 8:48 PM | Filed Under [ .NET ]

Feedback

Gravatar

# re: Localizing display properties in the PropertyGrid

Awesome sample. I do see one limitation though. You have to specify typeof(MyObject) in the MyObjectTypeDescriptionProvider, which means you have to create a TypeDescriptionProvider for every class you want to have a custom type descriptor for. It would be nice if there was a generic version of the TypeDescriptorProvider. I implemented mine like this: public class MyObjectTypeDescriptionProvider<T> : TypeDescriptionProvider

2/13/2006 7:45 PM | Matt Dotson
Gravatar

# re: Localizing display properties in the PropertyGrid

That last part should have been:

LocalizedTypeDescriptionProvider<T> : TypeDescriptionProvider {...}

And add it to MyObject like this:

[TypeDescriptionProvider(typeof(LocalizedTypeDescriptionProvider<MyObject>))]
public class MyObject
{ ... }
2/13/2006 7:54 PM | Matt Dotson
Gravatar

# re: Localizing display properties in the PropertyGrid

Thank you. You're right. My example was overly simple for the sake of clarity. I guess it wouldn't have been too complicated to use generics.
2/14/2006 7:36 AM | Anthony Trudeau

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 1 and 2 and type the answer here:

Powered by: