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

bala3569 picture bala3569 · Nov 24, 2010 · Viewed 172.7k times · Source

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);

Answer

BornToCode picture BornToCode · Sep 13, 2012

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.