1

I Have a Form that I have opened up as a dialog. On the Form I have a cancel and a correct button, I need to get the positive feedback from the form when the user selects the correct button. How would I go about linking the correct button to the OK Dialog result?

Mong Zhu
  • 23,309
  • 10
  • 44
  • 76
Sheenie
  • 143
  • 2
  • 9

1 Answers1

3

From MSDN Button.DialogResult Property comes this answer:

private void InitializeMyButton()
{
    // Create and initialize a Button.
    Button button1 = new Button();

    // Set the button to return a value of OK when clicked.
    button1.DialogResult = DialogResult.OK;

    // Add the button to the form.
    Controls.Add(button1);
}

applied to your case you would just simply assign this to the property of your correct button:

correct_btn.DialogResult = DialogResult.OK;
Mong Zhu
  • 23,309
  • 10
  • 44
  • 76