Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MessageBox buttons - set language?

Tags:

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.

like image 656
Frode Lillerud Avatar asked May 30 '09 22:05

Frode Lillerud


People also ask

Which is the default MessageBox button?

The first button on the message box is the default button.

What is MessageBox show in C#?

MessageBox is a class in C# and Show is a method that displays a message in a small window in the center of the Form. MessageBox is used to provide confirmations of a task being done or to provide warnings before a task is done. Create a Windows Forms app in Visual Studio and add a button on it.

Is MessageBox show a modal dialog window?

Definition. Displays a message window, also known as a dialog box, which presents a message to the user. It is a modal window, blocking other actions in the application until the user closes it. A MessageBox can contain text, buttons, and symbols that inform and instruct the user.


1 Answers

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

like image 165
Fredrik Mörk Avatar answered Oct 29 '22 02:10

Fredrik Mörk