I have many events on a Windows Forms form. I have a feedback label, and I have to write feedbaxk.Text=""; at the beginning of each event.
In ASP.NET, I have been using to write it only once in the page_load
event which is fired on every postback, but Form Load fires only once.
I have tried to search with the title of my question and found following two closest answers:
WinForms equivalent of ASP.NET page load event (PC Review)
There is some relevant material, but I could not get satisfying answer from these and many more.
How it can be detected in Windows Forms that an event is going to be fired?
Update: By googling it another way, I found a close link which is linked with another links, Find all event handlers for a Windows Forms control in .NET and Is it possible to “steal” an event handler from one control and give it to another?. After viewing these I think it is possible if
- I could get list of all events in a win-form say at the end of Form_Load (after that I don't add any more events). Then add a little common functionality (say changing a label text) to all events.
- I might be able to inherit all of my events from a parent one and add my desired functionality in that event and then add (override) specific functionality to each event.