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?
Asked
Active
Viewed 2,798 times
1
-
It says `when not using buttons` but the answer covers your case. – C4d Nov 29 '16 at 09:22
-
On your form's properties, there is `AcceptButton` and `CancelButton`. – active92 Nov 29 '16 at 09:23
1 Answers
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