PDA

View Full Version : DotNet Cancel Closing Event


BoubQC
05-04-2011, 06:01 PM
Hey guys! Is there a way to cancel a closing event of a form... i was thinking of an eventhandler with a function to cancel... but I really don't know how! I just want that is a form is closed it cancels and hide it so it ain't disposed. Thanks for your help! Found this on msdn but don't know how to make it happen! http://msdn.microsoft.com/en-us/library/system.componentmodel.canceleventargs.aspx

lo
05-04-2011, 10:01 PM
use this event and set cancel property to true
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.formclosing.aspx

denisT
05-04-2011, 10:01 PM
fn onClosing s e =
(
format "%\n" (e.CloseReason.ToString())
if e.CloseReason == e.CloseReason.UserClosing do
(
e.Cancel = on
s.Hide()
)
)
dotnet.addeventhandler form "Closing" onClosing



to close the form use Dispose() method

BoubQC
05-05-2011, 03:47 AM
Thanks guys! It works great and pretty simple! Thanks a lot!

CGTalk Moderation
05-05-2011, 03:47 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.