Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Localizing DisplayMember
 

Localizing DisplayMember

Hi everyone,

Does anyone happen to know why DisplayMember is not a localizable property in the designer (at least in VS2005)? I'm currently working on localizing an application that uses a lot of data binding and am unable to set different DisplayMember values for different languages without hard-coding the switch in my forms' Load() methods (somewhat tedious) or manually editing the resource files (not the most maintainable or error-free approach). I've developed my objects with different display properties for the different languages I have to deal with, and it would be nice to be able to set them the same way I am able to change a label or resize a component for each language.

Any thoughts?

Thanks,
TSK

TheSquirrelKing  Wednesday, April 01, 2009 3:18 PM

Hi TSK,

> Does anyone happen to know why DisplayMember is not a localizable property in the designer (at least in VS2005)?

In my opinion, only those properties directly related to UI are localizable, e.g.the Text property of a Label or Button.Apparently, the DataSource or DisplayMember property is not directly related to UI, so they are not localizable.

A solution to your problem is to add a field in the DB table to distinguish different cultures. For example, there's a States table in DB. Its definition is as follows:
ID int
Name varchar(50)
Culture varchar(10)

Store the culture/language name in the Culture field. For example:

ID Name Culture
1 aaa en-US
2aaa1en-ZW
3 aaa2 en-GB

Query the DB table according to the current UI culture name when the application starts(FYI, calltheThread.CurrentThread.CurrentUICulture.Name to get the current UI culture name).The DataSource and the DisplayMemeber properties remain the same.

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu

Linda Liu  Monday, April 06, 2009 7:33 AM

Hi TSK,

> Does anyone happen to know why DisplayMember is not a localizable property in the designer (at least in VS2005)?

In my opinion, only those properties directly related to UI are localizable, e.g.the Text property of a Label or Button.Apparently, the DataSource or DisplayMember property is not directly related to UI, so they are not localizable.

A solution to your problem is to add a field in the DB table to distinguish different cultures. For example, there's a States table in DB. Its definition is as follows:
ID int
Name varchar(50)
Culture varchar(10)

Store the culture/language name in the Culture field. For example:

ID Name Culture
1 aaa en-US
2aaa1en-ZW
3 aaa2 en-GB

Query the DB table according to the current UI culture name when the application starts(FYI, calltheThread.CurrentThread.CurrentUICulture.Name to get the current UI culture name).The DataSource and the DisplayMemeber properties remain the same.

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu

Linda Liu  Monday, April 06, 2009 7:33 AM

You can use google to search for other answers

Custom Search

More Threads

• Displaying different image size in a listview.
• Moving and copying windows form in visual studio 2005
• DomainUpDown->SelectedIndex property not available in Forms Designer
• The type or namespace name 'SQLCLient' does not exist in the namespace 'System.Data'
• Displaying list of typed datasets
• Add new method (add code to the class being designed)
• custom designer for smart device
• I cannot get designer view....
• Using Data Form Wizard - AddNew() adds new row but doesn't clear out databound controls
• Rich Text Box. Usage etc.