Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have tabbed windows forms application , if user close any tab i ask him
if he he need to save data or not , giving him option yes , no , cancel
i managed that situation by inherting from form that handel onclousing method , but if the user press the button new , it will show data in the same form , so the form is not closed although there is data must saved first , also if user press next or previous , alse if user is using search
and a new object is shown without saving the prevois , so i think of creating attribute for methods like "NewButton_Click" that attribute check if there are data unsaved or not in the form (i can get that form by parentform (activeform) )so it will show messege that ask if user need to save or not , if saving i will call save that is ovverrided in that active form
Posted

1 solution

You can't, AFAIK, specify a method that is called before all click events. You should factor your save if needed code to a method, and call THAT at the head of all events that need it.
 
Share this answer
 
Comments
hemayouness 28-Aug-10 19:26pm    
Postsharp made library for tracing methods

http://www.codeproject.com/KB/cs/ps-custom-attributes-1.aspx

they can run code onMethodEntry , onMethodExit

but it is not my situation

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900