all groups > dotnet windows forms > february 2005 >
You're in the

dotnet windows forms

group:

Cancel Form by using CausesValidation set to FALSE


Cancel Form by using CausesValidation set to FALSE Torsten Piehl
2/21/2005 2:34:34 PM
dotnet windows forms:
Hi newsgroup,

how can I suppress the validating_event from a control received the focus in
a modeless Form when pressing the cancel-Button or the ESC-Key?

I already set the CausesValidation-Property of the cancel-Button to FALSE,
without effect. If I set both properties to FALSE (cancel-Button and
validated_control) the validating_event is suppressed completely!
Any ideas?

Thanks and Regards,
Topi




Re: Cancel Form by using CausesValidation set to FALSE downeyt
9/4/2005 3:48:46 PM

I have the same problem. The form works properly if it is opened modall
with ShowDialog(): Cancel does not cause validation. If I open the for
modelessly with Show(), then the form does not behave properly: Cance
causes validation, but shouldn't.

I have set CausesValidation to false in the property editor and in th
Cancel button event. I have also set the DialogResult to Cancel in th
property editor and in the cancel handler.

The only solution I have found for the modeless case is to set a fla
in the Cancel button event handler, and test it in addition to m
validation statements in the validation handlers. This also require
that I catch the ESC key when it is pressed so I can set the flag, an
also to catch WM_SYSCOMMAND if there is a control box with a clos
button so I can set the flag. There has to be a better way

--
downey
-----------------------------------------------------------------------
downeyt's Profile: http://www.msusenet.com/member.php?userid=490
View this thread: http://www.msusenet.com/t-186978300
AddThis Social Bookmark Button