views:

1175

answers:

4

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 f.instance Norwegian messagetext the user still gets 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 languagepack at my client.

+3  A: 

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

Fredrik Mörk
A: 

I dont think it is possible but refer this article from MSDN. 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?

Shoban
+1  A: 

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.

Joey
A: 

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 agree on this.

Reinventing the wheel is definitely not an option. Relying on the Windows MessageBox with the constraints it has seems to be a much better choice. Features such as Modality and hotkeys; and various fixes are already taken care of and you don't have to go through it all again.

jessn