Click here to Skip to main content
15,896,524 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all,


Can anybody tell me how to call FormLoad event from an interface. I have a windows form which contains form load event & i want this formload event in interface, how do i do this.

Thanks in advance
Posted
Comments
phil.o 10-Mar-15 6:25am    
That does not make any sense. An interface does not carry any implementation, it just defines properties, methods and/or events that objects implementing it must have.
Moreover, FormLoad event is automatically fired when your form loads; if there is an event handler attached to it, then this event handler will execute. What prevents you from calling this event handler directly?
Sergey Alexandrovich Kryukov 10-Mar-15 7:48am    
There is no such concept as "call an event" and "call something from interface". It makes no sense.
—SA

1 solution

Is this what you mean?

C#
public interface IEditForm
{
        event EventHandler FormLoaded;

        event EventHandler EditButtonClicked;
        event EventHandler SaveButtonClicked;
        event EventHandler CancelButtonClicked;
        event EventHandler DeleteButtonClicked;
}


If yes, please accept, if not, please clarify.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 10-Mar-15 7:50am    
And what would be the use of it? :-)
—SA
[no name] 10-Mar-15 7:59am    
It's what I do for my WinForms-MVP-Pattern. I fuzzy-matched the question to something that made the most sense ;-)
- Sebastian
Sergey Alexandrovich Kryukov 10-Mar-15 8:00am    
Fair enough, a 5. ;-)
—SA
[no name] 10-Mar-15 8:22am    
Thank you :-)

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