C validating canceleventargs
The upshot here is that I'm looking into providing a cancellable events -and I was wondering how I might make use of Cancel Event Args. Myplan is to derive a new "event args" class from Cancel Event Args, and letthe client set the .
Cancel property - just like we can set that propertyfor the Form Closing event. Whatever code is actually instantiating your args class would check the flag after calling the method that raises the event, and the flag will be set if any of the code dealing with the event sets it. Without thinking it through very well it just seemed like something special might be going on, what with the delegate sitting between the event publisher and subscribers --- you know what we hear, "the event handler hides the subscribers from the publisher". But I doubt even that would make a difference at the end of the day (in terms of the publisher being able to see 'e' (eventargs instance).
I have some code that checks and makes sure that when the users enters in the field an integer from 1 - 10 has to be input.
Although if the users takes focus of the field, the "bad" data (such as "fdgfdg") is still left in the field.
I am not sure whether all the above three event handlers are required , what all pieces of code I must write in each event handler or any additional event handlers are required(if so, what code I must write inside them ) to achieve the above mentioned functionality That regex will fail to validate a lot of valid email addresses (you need to read RFC 2822 for what is valid).
Cancel property to subsequently know if further processing (e.g., actually close the form) is to be aborted? The code that instantiates the Cancel Event Args instance is likely the same code that calls On Form Closing to raise the event.