views:

66

answers:

2

hi. how can i provide F1 help support to .Net application.

the application consist of several form with many fields. so i dont want to drop HelpProvider control on each form and set the properties. please tell me any component that can handle this.

A: 

For WPF, you may do the following:

CommandBinding HelpBinding = new CommandBinding(
            ApplicationCommands.Help,
            ShowHelpHandler,
            CanShowHelpHandler);
CommandManager.RegisterClassCommandBinding(typeof(Window), HelpBinding);

where ShowHelpHandler and CanShowHelpHandler are declared as

static void ShowHelpHandler(object sender, ExecutedRoutedEventArgs e)
{
    ...
}
static void CanShowHelpHandler(object sender, CanExecuteRoutedEventArgs e)
{
    ...
}

This will register Help command bound to F1 at all windows.

Vlad
i want to use in winform
Mohsan
@Mohsan: sorry, have no experience with WinForms; please wait for other answers.
Vlad
+1  A: 

I suppose you could implement a class that inherits Form and adds a HelpProvider, then inherit your forms from that class. That way, you'd only have to set the properties

Form -> AppFormBase -> ConcreteForm

Public Class AppFormBase
  Inherits Form ' Your original base class

  Public Sub New()
    ' Add HelpProvider to Me.Controls
  End Sub
End Class

Public Class MyActualForm ' Your original form.
  Inherits AppFormBase

End Class
Arne Sostack
can u give me some example.... i am using SCSF framework for my application.
Mohsan
I'm sorry, I don't know this framework. If you look at what your forms currently inherit from, you may be able to change that into a class of your own, which inherits from the original base class of your form.Example added to answer.
Arne Sostack