Sunday, July 18, 2010

C# Tutorial: Create your own Custom Message Box

Here is the code

static CustomMsgBox MsgBox; static DialogResult result = DialogResult.No;
////////////////////////////////////////////////////////////////////////////////
public static DialogResult Show(string Text, string Caption, string btnOK, string btnCancel)
{
     MsgBox = new CustomMsgBox();
     MsgBox.label1.Text = Text;
     MsgBox.button1.Text = btnOK;
     MsgBox.button2.Text = btnCancel;
     MsgBox.Text = Caption;
     result = DialogResult.No;
     MsgBox.ShowDialog();
     return result;
}
////////////////////////////////////////////////////////////////////////////////
result = DialogResult.Yes; MsgBox.Close();

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Hi there,

    In the YouTube video, user "heidihas300" said that you need to reset the "result" otherwise it would be set to Yes every time. How did you resolve this?

    Thanks for a great video!

    ReplyDelete