How can I check the elements of a .NET dialog box when using the automatic DialogResult?
5 answers
You can use the functionality of the OK and Cancel buttons for dialogs, and then put this code in the Clicked handler for the OK button:
private void OkButton_Clicked(object sender, EventArgs e)
{
if (!IsValid()) {
this.DialogResult = System.Windows.Forms.DialogResult.None;
}
}
In the above code IsValid()
, this is the method you should implement that validates the input fields in the dialog.
0
source to share