简体   繁体   English

如何在CHM文件左侧的树视图中设置Selected项

[英]How to set the Selected item in the tree view on the Left side of CHM file

I have a CHM helpfile for my WPF Application. 我的WPF应用程序有一个CHM帮助文件。 My CHM file contains "htm" files for each page of my application. 我的CHM文件包含我的应用程序的每个页面的“htm”文件。 I want to open the help file for the corresponding page when the user presses F1 on that page. 我想在用户按下该页面上的F1时打开相应页面的帮助文件。 Right now I am able to locate the page and open that page by using the following code: 现在,我可以使用以下代码找到页面并打开该页面:

Help.ShowHelp(this, helpfile, keywordText);

where keywordText contains the URL of my htm file for the selected page. 其中keywordText包含所选页面的htm文件的URL。

But the problem is, that the panel on the left side (contents tab in a tree view) is not expanded to the page that opened in the right window. 但问题是,左侧的面板(树视图中的内容选项卡)未展开到右侧窗口中打开的页面。 The panel on the left side always remains the same. 左侧的面板始终保持不变。

How Can I expand the tree view on the left side to the selected page? 如何将左侧的树视图展开到所选页面?

Have a look at the code and the small GUI (snap attached). 看一下代码和小GUI(附带快照)。 The topics are refreshed after the users button click (eg Help Topic1). 用户按钮单击后刷新主题(例如帮助主题1)。

Please note the help file created with Microsoft HTMLHelp Workshop may need a auto sync parameter. 请注意,使用Microsoft HTMLHelp Workshop创建的帮助文件可能需要自动同步参数。

private void btnHelpTopic1_Click(object sender, EventArgs e)
{
    // sHTMLHelpFileName_ShowWithNavigationPane = "CHM-example_ShowWithNavigationPane.chm"
    // This is a HelpViewer Window with navigation pane for show case only 
    // created with Microsoft HTMLHelp Workshop
    helpProvider1.HelpNamespace = Application.StartupPath + @"\" + sHTMLHelpFileName_ShowWithNavigationPane;
    Help.ShowHelp(this, helpProvider1.HelpNamespace, @"/Garden/tree.htm");
}

private void btnHelpTopic2_Click(object sender, EventArgs e)
{
    helpProvider1.HelpNamespace = Application.StartupPath + @"\" + sHTMLHelpFileName_ShowWithNavigationPane;
    Help.ShowHelp(this, helpProvider1.HelpNamespace, @"/Garden/flowers.htm");
}

在此输入图像描述

For download I provide a C# VS2008 Project including the code above and the help files with different help viewer windows (different CHM files for show case only). 为了下载,我提供了一个C# VS2008项目,包括上面的代码和带有不同帮助查看器窗口的帮助文件(仅用于展示案例的不同CHM文件)。

Thanks. 谢谢。

The Problem is in the URL. 问题出在URL中。

Before that I gave a URL like this 在此之前我给了这样一个URL

"Help.CHM::/html/MyHelp.htm" “的help.chm :: / HTML / MyHelp.htm”

And when I removed "Help.CHM::/" from the URL and Everything Worked Well.. 当我从URL中移除“Help.CHM :: /”并且一切正常工作时...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM