DevTun
DevTun

Reputation: 880

HelperProvider always open the index file

I want to build a context sensitive help for a winforms application, to do this I use a class with a reference to the HelperProvider component, HelpNamespace is set to the index html file and when a form is loaded I register each control in the form to the helperprovider with a topic that I get from a config file :

helpProvider.SetShowHelp(control, true);
        helpProvider.SetHelpNavigator(control, helpNavigator);
        helpProvider.SetHelpKeyword(control, helpKeyword);

when debugging I am sure that some controls are configured with some topics different from index file but when running and pressing F1 its always the index file (HelpNamespace) that is opened. When using a HelperProvider instance for each control and no single instance for all controls, that works fine! Why I can't use a single instance of helperProvider for all controls?

Upvotes: 1

Views: 620

Answers (1)

help-info.de
help-info.de

Reputation: 7260

You need SetHelpKeyword for each control. A HelpNavigator.TopicId may be useful for a CHM with topic ID's inside.

I'm missing ".Topic" in your code sample above. Try the code below or download a working example from:
http://www.help-info.de/files_download/CSharp2008_CHM.zip

            // set F1 help topic for controls on this form
        helpProvider1.SetHelpNavigator(this.btnStart, HelpNavigator.Topic);
        helpProvider1.SetHelpKeyword(this.btnStart, @"/Garden/flowers.htm");
        helpProvider1.SetHelpNavigator(this.btnExit, HelpNavigator.Topic);
        helpProvider1.SetHelpKeyword(this.btnExit, @"/Garden/tree.htm");
        helpProvider1.SetHelpNavigator(this.chkShowHelpWithNavigationPane, HelpNavigator.Topic);
        helpProvider1.SetHelpKeyword(this.chkShowHelpWithNavigationPane, @"/HTMLHelp_Examples/jump_to_anchor.htm#AnchorSample");

Upvotes: 1

Related Questions