When a user press F1 on a control or click on Help button of form (?) and then clicks on a control the HelpRequested
event will be raised.
You can handle this event to provide custom action when user requests help for controls or form.
The HelpRequested
supports bubble up mechanism. It fires for your active control and if you don't handle the event and not set Handled
property of its event arg to true
, then it bubbles up to the parent control hierarchy up to form.
For example if you handle HelpRequested
event of the form like below, then when you press F1 a message box will pop up and show name of active control, but for textBox1
it will show a different message:
private void Form1_HelpRequested(object sender, HelpEventArgs hlpevent)
{
var c = this.ActiveControl;
if(c!=null)
MessageBox.Show(c.Name);
}
private void textBox1_HelpRequested(object sender, HelpEventArgs hlpevent)
{
hlpevent.Handled = true;
MessageBox.Show("Help request handled and will not bubble up");
}
You can perform any other custom action like using navigating to a URL or showing a CHM file using Help
class.