Globalization of Menus

T

Thore Berntsen

I'm working on globalization of my retail Pocket PC application.

I found much help in this article the article "Build World-Ready Device
Applications" on MSDN.
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/worldready.asp)

The only thing I need help with, wich this article dosen't cover, is menus.
I could fix that myself, but I need to find the Name (not Text!) of every
MenuItem component on my Form. Does anyone have any ideas on how this can be
done?

Thore Berntsen
VBD, Norway.
 
T

Thore Berntsen

I want to find all MenuItem's on my Form and lookup the gloablized text in
my resource dll's using ResourceManager.GetString. My resources is organized
the same way that in the MSDN article. That means that I have to get the
name of the MenuItem in order to pass it to the GetString method. I could of
course hardcode this, but I'm trying to automate this process a bit (againt
see the MSDN article)

Thore
 
D

Daniel Moth

MenuItem inherits from Menu : Component : MarshalByRefObject : Object
So as you can see there is no Control in that hierarchy which is why the
approach discussed in the article does not work. I am aware of no other way
of getting the name of a menu item.

What you could do is create your own MenuItemEx that adds that property
e.g.:
namespace System.Windows.Forms{
public class MenuItemEx : MenuItem{
public string Name;
}
}

Then wherever you have a MenuItem declared change the declaration to
MenuItemEx and do the same for where it gets created (= new MenuItemEx).
Then explicitly set the Name property to some string and use that in your
resources. Frankly, I wouldn't get into all that trouble as you will lose
designer support either for the menus because you will add them in your
constructor/OnLoad or for the entire form if you choose to directly edit the
InitializeComponent.

Regardless of the above, I wouldn't use the approach described in the
article at all. It is much slower than hardcoding the control IDs. NETCF
form startup (which is where assigning Text usually take place) is slow
enough as it is without adding reflection to it. Plus I wouldn't want to tie
myself to a scheme where I cannot change control names later due to
refactoring or whatever.

Cheers
Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

CF1.1 multi-language support 1
DEFRAGMENTATION OF STORAGE CARD 9
Uniqe identification of devices 3
DLLimport 5
Sending SMS 2
How to get the Assembly Version Number 3
serial comm 2
SetupHelper.dll 2

Top