Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the button text for 'Yes' and 'No' buttons in the MessageBox.Show dialog?

I need to change the message box control buttons Yes to Continue and No to Close. How do I change the button text?

Here is my code:

 DialogResult dlgResult = MessageBox.Show("Patterns have been logged successfully", "Logtool", MessageBoxButtons.YesNo, MessageBoxIcon.Information); 
like image 283
bala3569 Avatar asked Nov 24 '10 08:11

bala3569


People also ask

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.

Which is the default MessageBox button?

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


1 Answers

I didn't think it would be that simple! go to this link: https://www.codeproject.com/Articles/18399/Localizing-System-MessageBox

Download the source. Take the MessageBoxManager.cs file, add it to your project. Now just register it once in your code (for example in the Main() method inside your Program.cs file) and it will work every time you call MessageBox.Show():

    MessageBoxManager.OK = "Alright";     MessageBoxManager.Yes = "Yep!";     MessageBoxManager.No = "Nope";     MessageBoxManager.Register(); 

See this answer for the source code here for MessageBoxManager.cs.

like image 190
BornToCode Avatar answered Sep 19 '22 14:09

BornToCode