Question

When you use MessageBox.Show() you have a selection of MessageBoxButtons to choose from. The buttons available are an enum, and give you options like "Yes No", "OK Cancel", etc.

When I am using, for instance, Norwegian message text the user still gets the English "Yes No".

Is there a way to change the text of the buttons (in C#) so that the language is correct? Can I override the text, or set the current locale in some way so that I can have "Ja Nei" instead of "Yes No"?

I do not want to rely on installing a .NET language pack at my client.

Was it helpful?

Solution

There is no native support for this in .NET (as far as I know, anyway; please correct me if I'm wrong, anyone). I did come across this CodeProject article, that seem to do the trick with some message hooking and P/Invoke: http://www.codeproject.com/KB/miscctrl/Localizing_MessageBox.aspx

OTHER TIPS

Usually messagebox buttons (as all of Windows) honor the currently set UI language for Windows. So if you've got an English installation and can't change languages (MUI versions or Ultimate for Vista/7) you're out of luck.

You could implement a messagebox yourself but I'd beg you not to. Simple things like common hotkeys for the buttons, having the ability to use Ctrl+Ins to copy the contents, etc. are the ones I miss the most when people start reinventing square wheels.

I don't think it is possible, but refer to the MSDN article MessageBox.Show Method. You may get some ideas. You can change the text in the message box. What about creating your own message box (new form) and displaying them?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top