Abort form closing

A

Aleksey Timonin

Hi guys,
I show my Form in dialog mode. So I have "Ok" button on it with DialogResult
= Ok. What is the right way and how can I abort form closing from the button
click event.

Thanks a lot
Aleksey
 
N

Nicholas Paldino [.NET/C# MVP]

Aleksey,

I don't believe you should do this from the button click event. Rather,
you need to subscribe to the Closing event on your form, and then set the
Cancel property to true on the CancelEventArgs passed to your event handler.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top