Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

hi

i want to open the help file of my application whenever user press F1 in any of my 84 forms.

so should I enable the keypreview of all my forms and check if user press F1 in each form to show the help file?

because i heard that it's not recommended to enable the form key preview.

is there any other way?

thanks

  • Leaders
Posted

Who says that it is not recommended to enable KeyPreview, and why? It isn't necessary in this case, though. It seems that the active control, its container, its container's container, etc., will all raise the HelpRequested event when the user presses F1 (this includes the active form).

 

I recommend that you create a static class that will handle all of the Forms' HelpRequested events, that way you can have a small amount of code in one place that handles this feature. You can either create a new Form class that does this and derive all 84 of your forms from that or you can add a statement to each form's constructor that adds that form's HelpRequested event to the class' HelpRequested event handler.

 

Beware, though, that this event seems to be raised more than once when the user presses F1. When you handle the event, be sure the set the HelpEventArgs.Handled property to true to prevent the event from being raised again.

[sIGPIC]e[/sIGPIC]
  • Leaders
Posted

You can do whatever you like when the user presses F1.

 

The important things you need to know are:

  • The HelpRequested event is raised when F1 is pressed.
  • You handle this event in any way you like.
  • Be sure to set the HelpEventArgs.Handled property to true if you handle the event.
  • The HelpRequested event is actually intended to be used for context-sensitive help and can also be raised by clicking the question mark button in the title bar if this button is displayed on your form, so make sure that you don't require the use of this feature if you choose this solution.

[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...