Hi,
I am using windows form. Now in this window i have 2 textboxes which have their validation using the error provider. Now i want that when the user clicks on the close button it closes not rests until u enter something in the textboxes. How can i do so?

Recommended Answers

All 4 Replies

What do you have now in your close_button_Clicked(...) method?

is there any property or no?

is there any property or no?

go to form event and write your logic to check validation in its closing event.

For Example: If your form is Form1 then,

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{

}

thank you very much! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.