4
Answers

Textbox validate event should not fire when I close the form

jalajakshi p

jalajakshi p

15y
8.4k
1

Hi,

In windows application(c#) I am having a form which contains two textboxes.

For one textbox I have created validate event.like below

private void txtProposedNextDueDate_Validating(object sender, CancelEventArgs e)

{

if (txtProposedNextDueDate.Text == "")

{

MessageBox.Show("Please enter valid date"); txtProposedNextDueDate.Focus();

}

}

But when I want to close the form without entering any value,then also it is showing the messagebox and then it is closing the form.

So when I close the form I dont want to validate the textbox.Simply it should close the form without showing message.

Answers (4)