Home All Groups Group Topic Archive Search About

.NET property names and translation

Author
31 Jan 2007 2:30 PM
John Allen
Hi there,

Does anyone know if the standard "PropertyGrid" control is (foreign)
language sensitive. If I display an object in the control, and my object has
the native .NET "Size" struct as a property (which also contains its own
""Width" and "Height"  members), will someone running my app on a German
version of Windows for instance still see "Size", "Width" and "Height" in
the property window. Or does it get translated into German accordingly. If
not then how would I translate it. Thanks.

Author
31 Jan 2007 5:55 PM
Stoitcho Goutsev (100)
John,

This can be definitely done. There are two things you need to localize -
property names and category names.
The category are easy to localize. Just inherit your own class from the
CategoryAttribute and override its GetLocalizedString virtual method. This
method is called by the Category property first time the property is read.
Here you need to return your localized version of the category name.

With the property names it is not that easy. The property grid uses
PropertyDescriptor objects to display and manipulate object proeprties. For
the property name it reads the DisplayName property of the
PropertyDescriptor. DisplayName is virtual, but read only so it can be only
override to return localized version of the property name. I believe you can
create your own PropertyDescriptor class that iherits from the
PropertyDescriptor and overrides DisplayName p then you can create
TypeConverter the return colleciton of this special property descritors for
the class properties upon calling GetProperties method.
You can also implement a ICustomTypeDescriptor interface

Actually I looked around on the net and I found pretty good article for you
with a sample code

http://www.codeproject.com/cs/miscctrl/gpg_revisited.asp

HTH

--
Stoitcho Goutsev (100)

Show quote
"John Allen" <no_spam@_nospam.com> wrote in message
news:%2367MqRURHHA.1860@TK2MSFTNGP06.phx.gbl...
> Hi there,
>
> Does anyone know if the standard "PropertyGrid" control is (foreign)
> language sensitive. If I display an object in the control, and my object
> has the native .NET "Size" struct as a property (which also contains its
> own ""Width" and "Height"  members), will someone running my app on a
> German version of Windows for instance still see "Size", "Width" and
> "Height" in the property window. Or does it get translated into German
> accordingly. If not then how would I translate it. Thanks.
>
Author
31 Jan 2007 5:55 PM
Stoitcho Goutsev (100)
John,

This can be definitely done. There are two things you need to localize -
property names and category names.
The category are easy to localize. Just inherit your own class from the
CategoryAttribute and override its GetLocalizedString virtual method. This
method is called by the Category property first time the property is read.
Here you need to return your localized version of the category name.

With the property names it is not that easy. The property grid uses
PropertyDescriptor objects to display and manipulate object proeprties. For
the property name it reads the DisplayName property of the
PropertyDescriptor. DisplayName is virtual, but read only so it can be only
override to return localized version of the property name. I believe you can
create your own PropertyDescriptor class that iherits from the
PropertyDescriptor and overrides DisplayName p then you can create
TypeConverter the return colleciton of this special property descritors for
the class properties upon calling GetProperties method.
You can also implement a ICustomTypeDescriptor interface

Actually I looked around on the net and I found pretty good article for you
with a sample code

http://www.codeproject.com/cs/miscctrl/gpg_revisited.asp

HTH

--
Stoitcho Goutsev (100)

Show quote
"John Allen" <no_spam@_nospam.com> wrote in message
news:%2367MqRURHHA.1860@TK2MSFTNGP06.phx.gbl...
> Hi there,
>
> Does anyone know if the standard "PropertyGrid" control is (foreign)
> language sensitive. If I display an object in the control, and my object
> has the native .NET "Size" struct as a property (which also contains its
> own ""Width" and "Height"  members), will someone running my app on a
> German version of Windows for instance still see "Size", "Width" and
> "Height" in the property window. Or does it get translated into German
> accordingly. If not then how would I translate it. Thanks.
>
Author
31 Jan 2007 6:34 PM
John Allen
Show quote
> This can be definitely done. There are two things you need to localize -
> property names and category names.
> The category are easy to localize. Just inherit your own class from the
> CategoryAttribute and override its GetLocalizedString virtual method. This
> method is called by the Category property first time the property is read.
> Here you need to return your localized version of the category name.
>
> With the property names it is not that easy. The property grid uses
> PropertyDescriptor objects to display and manipulate object proeprties.
> For the property name it reads the DisplayName property of the
> PropertyDescriptor. DisplayName is virtual, but read only so it can be
> only override to return localized version of the property name. I believe
> you can create your own PropertyDescriptor class that iherits from the
> PropertyDescriptor and overrides DisplayName p then you can create
> TypeConverter the return colleciton of this special property descritors
> for the class properties upon calling GetProperties method.
> You can also implement a ICustomTypeDescriptor interface
>
> Actually I looked around on the net and I found pretty good article for
> you with a sample code
>
> http://www.codeproject.com/cs/miscctrl/gpg_revisited.asp

Thanks very much. Somone else also referred me to a "codeproject" article
but I haven't located it yet (I assume it's the same as yours). I will look
into it. As for the other info, I've also been looking into that for several
days now and am finally getting my head wrapped around the details (though
I'll be relying on the "TypeDescriptionProvider" attribute instead of
inheriting from "ICustomTypeDescriptor" directly). Customizing a
"PropertyGrid" is no easy task needless to say. I was hoping at the very
least that the native .NET properties would be automatically translated
(where appropriate) but that was wishful thinking. In any case, on a
separate issue, do you know off-hand if it's possible to change the
font/color of an individual "PropertyGrid" row. I don't believe so based on
my research (without a lot of pain) but I'm hoping someone knows better.
Anyway, thanks again.
Author
31 Jan 2007 7:52 PM
Stoitcho Goutsev (100)
John,

I don't want to disapoint, but I don't think you can change the font or
color of individual rows.
As far as TypeDescriptionProvider goes just keep in mind that it is not
supported by pre 2.0 versions of the framework (I believe you already know
that)


--
Stoitcho Goutsev (100)


Show quote
"John Allen" <no_spam@_nospam.com> wrote in message
news:uwsQ6ZWRHHA.4844@TK2MSFTNGP03.phx.gbl...
>> This can be definitely done. There are two things you need to localize -
>> property names and category names.
>> The category are easy to localize. Just inherit your own class from the
>> CategoryAttribute and override its GetLocalizedString virtual method.
>> This method is called by the Category property first time the property is
>> read. Here you need to return your localized version of the category
>> name.
>>
>> With the property names it is not that easy. The property grid uses
>> PropertyDescriptor objects to display and manipulate object proeprties.
>> For the property name it reads the DisplayName property of the
>> PropertyDescriptor. DisplayName is virtual, but read only so it can be
>> only override to return localized version of the property name. I believe
>> you can create your own PropertyDescriptor class that iherits from the
>> PropertyDescriptor and overrides DisplayName p then you can create
>> TypeConverter the return colleciton of this special property descritors
>> for the class properties upon calling GetProperties method.
>> You can also implement a ICustomTypeDescriptor interface
>>
>> Actually I looked around on the net and I found pretty good article for
>> you with a sample code
>>
>> http://www.codeproject.com/cs/miscctrl/gpg_revisited.asp
>
> Thanks very much. Somone else also referred me to a "codeproject" article
> but I haven't located it yet (I assume it's the same as yours). I will
> look into it. As for the other info, I've also been looking into that for
> several days now and am finally getting my head wrapped around the details
> (though I'll be relying on the "TypeDescriptionProvider" attribute instead
> of inheriting from "ICustomTypeDescriptor" directly). Customizing a
> "PropertyGrid" is no easy task needless to say. I was hoping at the very
> least that the native .NET properties would be automatically translated
> (where appropriate) but that was wishful thinking. In any case, on a
> separate issue, do you know off-hand if it's possible to change the
> font/color of an individual "PropertyGrid" row. I don't believe so based
> on my research (without a lot of pain) but I'm hoping someone knows
> better. Anyway, thanks again.
>
Author
31 Jan 2007 6:34 PM
John Allen
Show quote
> This can be definitely done. There are two things you need to localize -
> property names and category names.
> The category are easy to localize. Just inherit your own class from the
> CategoryAttribute and override its GetLocalizedString virtual method. This
> method is called by the Category property first time the property is read.
> Here you need to return your localized version of the category name.
>
> With the property names it is not that easy. The property grid uses
> PropertyDescriptor objects to display and manipulate object proeprties.
> For the property name it reads the DisplayName property of the
> PropertyDescriptor. DisplayName is virtual, but read only so it can be
> only override to return localized version of the property name. I believe
> you can create your own PropertyDescriptor class that iherits from the
> PropertyDescriptor and overrides DisplayName p then you can create
> TypeConverter the return colleciton of this special property descritors
> for the class properties upon calling GetProperties method.
> You can also implement a ICustomTypeDescriptor interface
>
> Actually I looked around on the net and I found pretty good article for
> you with a sample code
>
> http://www.codeproject.com/cs/miscctrl/gpg_revisited.asp

Thanks very much. Somone else also referred me to a "codeproject" article
but I haven't located it yet (I assume it's the same as yours). I will look
into it. As for the other info, I've also been looking into that for several
days now and am finally getting my head wrapped around the details (though
I'll be relying on the "TypeDescriptionProvider" attribute instead of
inheriting from "ICustomTypeDescriptor" directly). Customizing a
"PropertyGrid" is no easy task needless to say. I was hoping at the very
least that the native .NET properties would be automatically translated
(where appropriate) but that was wishful thinking. In any case, on a
separate issue, do you know off-hand if it's possible to change the
font/color of an individual "PropertyGrid" row. I don't believe so based on
my research (without a lot of pain) but I'm hoping someone knows better.
Anyway, thanks again.
Author
31 Jan 2007 7:52 PM
Stoitcho Goutsev (100)
John,

I don't want to disapoint, but I don't think you can change the font or
color of individual rows.
As far as TypeDescriptionProvider goes just keep in mind that it is not
supported by pre 2.0 versions of the framework (I believe you already know
that)


--
Stoitcho Goutsev (100)


Show quote
"John Allen" <no_spam@_nospam.com> wrote in message
news:uwsQ6ZWRHHA.4844@TK2MSFTNGP03.phx.gbl...
>> This can be definitely done. There are two things you need to localize -
>> property names and category names.
>> The category are easy to localize. Just inherit your own class from the
>> CategoryAttribute and override its GetLocalizedString virtual method.
>> This method is called by the Category property first time the property is
>> read. Here you need to return your localized version of the category
>> name.
>>
>> With the property names it is not that easy. The property grid uses
>> PropertyDescriptor objects to display and manipulate object proeprties.
>> For the property name it reads the DisplayName property of the
>> PropertyDescriptor. DisplayName is virtual, but read only so it can be
>> only override to return localized version of the property name. I believe
>> you can create your own PropertyDescriptor class that iherits from the
>> PropertyDescriptor and overrides DisplayName p then you can create
>> TypeConverter the return colleciton of this special property descritors
>> for the class properties upon calling GetProperties method.
>> You can also implement a ICustomTypeDescriptor interface
>>
>> Actually I looked around on the net and I found pretty good article for
>> you with a sample code
>>
>> http://www.codeproject.com/cs/miscctrl/gpg_revisited.asp
>
> Thanks very much. Somone else also referred me to a "codeproject" article
> but I haven't located it yet (I assume it's the same as yours). I will
> look into it. As for the other info, I've also been looking into that for
> several days now and am finally getting my head wrapped around the details
> (though I'll be relying on the "TypeDescriptionProvider" attribute instead
> of inheriting from "ICustomTypeDescriptor" directly). Customizing a
> "PropertyGrid" is no easy task needless to say. I was hoping at the very
> least that the native .NET properties would be automatically translated
> (where appropriate) but that was wishful thinking. In any case, on a
> separate issue, do you know off-hand if it's possible to change the
> font/color of an individual "PropertyGrid" row. I don't believe so based
> on my research (without a lot of pain) but I'm hoping someone knows
> better. Anyway, thanks again.
>
Author
31 Jan 2007 8:29 PM
John Allen
> I don't want to disapoint, but I don't think you can change the font or
> color of individual rows.

I didn't think so and it's quite surprising to me actually.

> As far as TypeDescriptionProvider goes just keep in mind that it is not
> supported by pre 2.0 versions of the framework (I believe you already know
> that)

Yes, I'm aware of that. My app is targetting 2.0 and later so it's not an
issue. Anyway, thanks again. You've been very helpful.
Author
31 Jan 2007 8:29 PM
John Allen
> I don't want to disapoint, but I don't think you can change the font or
> color of individual rows.

I didn't think so and it's quite surprising to me actually.

> As far as TypeDescriptionProvider goes just keep in mind that it is not
> supported by pre 2.0 versions of the framework (I believe you already know
> that)

Yes, I'm aware of that. My app is targetting 2.0 and later so it's not an
issue. Anyway, thanks again. You've been very helpful.
Author
1 Feb 2007 1:03 AM
VisualHint
Hello John,

I think you have now 2 different codeproject articles to solve your
issue ;)

Concerning the colors, the MSPG won't do it but Smart PropertyGrid
will. Almost every visual aspect is customizable.

Best regards,

Nicolas Cadilhac @ VisualHint (http://www.visualhint.com)
Home of Smart PropertyGrid for .Net and MFC
Microsoft PropertyGrid Resource List - http://
www.propertygridresourcelist.com


Show quote
On Jan 31, 3:29 pm, "John Allen" <no_spam@_nospam.com> wrote:
> > I don't want to disapoint, but I don't think you can change the font or
> > color of individual rows.
>
> I didn't think so and it's quite surprising to me actually.
>
> > As far as TypeDescriptionProvider goes just keep in mind that it is not
> > supported by pre 2.0 versions of the framework (I believe you already know
> > that)
>
> Yes, I'm aware of that. My app is targetting 2.0 and later so it's not an
> issue. Anyway, thanks again. You've been very helpful.
Author
1 Feb 2007 12:51 PM
John Allen
Show quote
> Hello John,
>
> I think you have now 2 different codeproject articles to solve your
> issue ;)
>
> Concerning the colors, the MSPG won't do it but Smart PropertyGrid
> will. Almost every visual aspect is customizable.
>
> Best regards,
>
> Nicolas Cadilhac @ VisualHint (http://www.visualhint.com)
> Home of Smart PropertyGrid for .Net and MFC
> Microsoft PropertyGrid Resource List - http://
> www.propertygridresourcelist.com

Shameless plug :) but I'll check it out anyway (thanks)

AddThis Social Bookmark Button