0

in a message box there are 2 buttons, Yes and No. I want to have checkbox inside of message box which says Do it for all items , So if the button yes is selected , that is true for all items and if no is selected , that is true for all items.

Is it possible in messagebox?

Vignesh Kumar A
  • 27,863
  • 13
  • 63
  • 115
nnmmss
  • 2,850
  • 7
  • 39
  • 67

1 Answers1

1

The answer to your question is no. You cannot create a messagebox with a checkbox. You would have to create a custom dialog box. You need to create a form that looks the way you wish it to look and use the ShowDialog() method to display the form. This will display a modal dialog box in your application. The code after the ShowDialog method is not executed until the dialog box is closed.

using (Form2 frm = new Form2())
            {
                frm.ShowDialog();
                if (frm.DialogResult == DialogResult.Yes)
                {

                }
                else if (frm.DialogResult == DialogResult.No)
                {

                }
            }

On clicking yes or no from within the dialog box, you would do the following to close the dialog box with a DialogResult

  private void btnYes_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Yes;
        }

  private void btnNo_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.No;
        }
Jesse Petronio
  • 693
  • 5
  • 11