By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,481 Members | 979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,481 IT Pros & Developers. It's quick & easy.

How to do this the .Net way.

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.

"Chris" <no@spam.com> wrote in message
news:O3**************@TK2MSFTNGP14.phx.gbl...
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

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.