473,386 Members | 1,652 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,386 software developers and data experts.

.NET property names and translation

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.
Jan 31 '07 #1
4 2783
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/miscct..._revisited.asp

HTH

--
Stoitcho Goutsev (100)

"John Allen" <no_spam@_nospam.comwrote in message
news:%2****************@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.

Jan 31 '07 #2
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/miscct..._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.
Jan 31 '07 #3
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)
"John Allen" <no_spam@_nospam.comwrote in message
news:uw**************@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/miscct..._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.

Jan 31 '07 #4
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.
Jan 31 '07 #5

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

Similar topics

6
by: manuel | last post by:
Exist a sintax like import Foo for property in Foo print property ?
3
by: gry | last post by:
I often find myself wanting an instance attribute that can take on only a few fixed symbolic values. (This is less functionality than an enum, since there are no *numbers* associated with the...
0
by: George VS | last post by:
Thanks, Can anyone give me a table with translations character entity names to unicode values, that is: &Aacute; -> &#x00c1; &aring; -> &#x00E5; &Ecy; -> &#x042D; .... this EXACTLY what i...
10
by: crjunk | last post by:
I have a script that I want to run only when my input box IS NOT disabled. Can someone tell me if something is wrong with my script? Is "disabled" the correct property to use? function...
3
by: TGF | last post by:
Hello, When I attempt to set the icon property on a Windows form (.NET), when I go to compile, I get the following error.... e:\Projects\MyApp\AboutForm.h(108): error C2039: 'GetObjectA' : is...
16
by: John | last post by:
Does the length of my C variable names have any affect, performance-wise, on my final executable program? I mean, once compiled, etc., is there any difference between these two: number = 3; n =...
1
by: Mahmoud Al-Qudsi | last post by:
To make it easier for translators to convert my program to their local language, I'm using XML files as translation dictionaries since its much easier for deployment and production purposes. ...
4
by: | last post by:
Given an XML file (dataset.writexml), here is my output (simplified for this posting): <?xml version="1.0" standalone="yes"?> <NewDataSet> <Category> <CategoryId>80</CategoryId>...
3
by: SRoubtsov | last post by:
Dear all, Do you know whether ANSI C (or some other dialects) support the following: * a variable name coincides with a type name, * a structure/union field name coincides with a type name in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.