Click here to Skip to main content
15,880,972 members
Please Sign up or sign in to vote.
2.41/5 (3 votes)
See more:
I need to perform a forms Event without making that happen.

For Example;

frmOrderNew is the form.

C#
private void frmOrderNew_FormClosing(object sender, FormClosingEventArgs e)


How to programatically achieve this.
Posted
Updated 28-Aug-14 3:26am
v2
Comments
[no name] 28-Aug-14 9:12am    
"How to programatically achieve"... how to achieve what?
KUMAR619 28-Aug-14 9:17am    
The above mentioned Event handler
[no name] 28-Aug-14 10:12am    
To "achieve" something you have to have a goal. "The above mentioned Event handler" is not a goal and therefore not achievable. You really need to work on clearly identifying a problem and being able to communicate.
Vinay Mistry 28-Aug-14 9:32am    
Question is not proper.
Please be in details
Valery Possoz 28-Aug-14 9:34am    
if you need to execute the code that is in the event without firing the event I would suggest you refactor your code and do it another way. for example you could put the code that is in the event in a separate method and call this method where ever it is needed.

As mentioned in comments, you need to move whatever code you want to call into its own method. Then you can call it whenever you want including in the event for FormClosing. That is the proper way to do it.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 28-Aug-14 16:15pm    
Absolutely, a 5.
I would add that this is impossible to invoke any event from anywhere except declaring type.
—SA
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 28-Aug-14 16:15pm    
This is a really bad advice. The good one is Solution 2.
—SA
Bernhard Hiller 29-Aug-14 2:53am    
Well, I know some people who really use that WTF pattern...
You need to separate concerns!

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