using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Test_SimpleCustomMessageBox { public partial class SimpleCustomMsgBox : Form { public SimpleCustomMsgBox() { InitializeComponent(); } private static DialogResult result = DialogResult.No; public static DialogResult Show(string text, string caption, string btnOkText) { var msgBox = new SimpleCustomMsgBox(); msgBox.labelText.Text = text; //The text for the label... msgBox.Text = caption; //Title of form msgBox.buttonOK.Text = btnOkText; //Text on the button //This method is blocking, and will only return once the user //clicks ok or closes the form. msgBox.ShowDialog(); return result; } private void buttonOK_Click(object sender, EventArgs e) { result = DialogResult.Yes; this.Close(); } } }