HI, I'm extending a windows application written in C# to provide help to the user (in the context of the focused control) when they hit the F1 key.
What I’d like to do is make use of the Control.HelpRequested event but I’m not sure how to extend all the controls to handle this event. http://msdn.microsoft.com/en-us/library/system.windows.forms.control.helprequested.aspx
It’s not really feasible to update each control “by hand” to handle this event and I really don’t like the idea of looping through all the controls in a form (as the form opens) to associate the event handler.
Is there a neat way to extend all controls of a form to handle a specific event?
This is just made up but i almost feel like i should be able to write something like this
[HandleEvent Control.HelpRequested, ApplyTo Typeof(Control)] void MyEventHandler(object sender, EventArgs e) { // code to handle event... }
Any suggestions or perhaps ideas on a different approach are much appreciated - Thanks