Geeks With Blogs

News

View Anthony Trudeau's profile on LinkedIn

Add to Technorati Favorites


Anthony Trudeau

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

Posted on Friday, December 30, 2005 8:48 PM .NET | Back to top


Comments on this post: Localizing display properties in the PropertyGrid

# re: Localizing display properties in the PropertyGrid
Requesting Gravatar...
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

Left by Matt Dotson on Feb 13, 2006 7:45 PM

# re: Localizing display properties in the PropertyGrid
Requesting Gravatar...
That last part should have been:

LocalizedTypeDescriptionProvider<T> : TypeDescriptionProvider {...}

And add it to MyObject like this:

[TypeDescriptionProvider(typeof(LocalizedTypeDescriptionProvider<MyObject>))]
public class MyObject
{ ... }
Left by Matt Dotson on Feb 13, 2006 7:54 PM

# re: Localizing display properties in the PropertyGrid
Requesting Gravatar...
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.
Left by Anthony Trudeau on Feb 14, 2006 7:36 AM

Your comment:
 (will show your gravatar)


Copyright © Anthony Trudeau | Powered by: GeeksWithBlogs.net