How to do this the .Net way.

C

Chris

I am making a form template that will be used across our windows
applications. It will be used several hundred times. I so created a
class called FormTemplate and inherited that from Form. All our future
forms will inherit from FormTemplate. Want I need to happen is for
FormTemplate to catch when F1-F10 keys are press and fire off some
events for the inherited form to be able to catch.

Two issues I don't understand.
1. How do I make it so that even if the inherited form overrides the
keypress event, my form still gets the F1 key and fires the event.

2. What is the best way to expose the F1 Key event to the inherited
form? Should I be using an interface to force them?

Thanks for reading, hope you can help.
Chris
 
B

Bob Powell [MVP]

From your description I think that you need to override ProcessCmdKey to
trap the keys that you're interested in. To pass this information on to
derived classes you can use an overridable method which inherited classes
can use to trap each special key event.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top