HelperProvider始终打开索引文件

时间:2012-11-13 09:28:05

标签: winforms chm context-sensitive-help

我想为winforms应用程序构建一个上下文相关帮助,为此我使用一个引用HelperProvider组件的类,将HelpNamespace设置为索引html文件,并在加载表单时注册每个控件helperprovider的表单,其中包含我从配置文件中获取的主题:

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

调试时我确定某些控件配置了一些与索引文件不同的主题,但在运行并按F1时,它始终是打开的索引文件(HelpNamespace)。当为每个控件使用HelperProvider实例而对所有控件都没有单个实例时,这样可以正常工作! 为什么我不能为所有控件使用helperProvider的单个实例?

1 个答案:

答案 0 :(得分:1)

每个控件都需要SetHelpKeyword。 HelpNavigator.TopicId可能对包含主题ID的CHM有用。

我在上面的代码示例中缺少“.Topic”。请尝试以下代码或从以下位置下载工作示例:
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");
相关问题