html帮助文件与c#连接 急!

zhangyanyang 2009-04-23 10:49:56
我已经用HTML HELP WORKSHOP 软件编好了一个方案文件"wode方案",不知如何与c#交互,如何在编辑好的软件中点F1显示“wode方案”;请教各位高手?急急急
...全文
152 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhangyanyang 2009-04-24
  • 打赏
  • 举报
回复
谢谢楼上各位呢关注
zhangyanyang 2009-04-23
  • 打赏
  • 举报
回复

System.Diagnostics.Process.Start("F:/我的项目/HTML"+"方案文件.chm");

是不是这样?
himoggy 2009-04-23
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 zhangyanyang 的回复:]
C# code
private void 帮助ToolStripMenuItem_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start(Application.StartupPath+"方案文件.chm");
}



找不到指定文档?
[/Quote]

Application.StartupPath是你程序启动目录 具体你可以自己设置
另外- -这个时候加个容错吧,如果找不到该文件就跳过
try{}catch{} 或者if(File.Exists(文件))
zhangyanyang 2009-04-23
  • 打赏
  • 举报
回复

private void 帮助ToolStripMenuItem_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start(Application.StartupPath+"方案文件.chm");
}

找不到指定文档?
zgke 2009-04-23
  • 打赏
  • 举报
回复
void Form1_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.F1)
{
System.Diagnostics.Process.Start(application.StartupPath+"wode方案.chm"); }
}

private void Form1_Load(object sender, EventArgs e)
{
this.KeyPreview = true;

this.KeyUp += new KeyEventHandler(Form1_KeyUp);
}
zhangyanyang 2009-04-23
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 mountplorer 的回复:]
不会,这也提问,
[/Quote]
先回答了再说撒,
mountplorer 2009-04-23
  • 打赏
  • 举报
回复
不会,这也提问,
zhangyanyang 2009-04-23
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 hilarymoggy 的回复:]
界面上做个按钮 快捷键设为F1
然后直接System.Diagnostics.Process.Start(application.StartupPath+"wode方案.chm");就行
= =不知道有没有拼写错

如果是要制定跳转到某夜那就麻烦些了
一般只要打开文件就行了吧?
[/Quote]
再请问下,System.Diagnostics.Process.Start(application.StartupPath+"wode方案.chm");在按钮——click时间下写吗
还有F1快捷键怎么设?点F1的时候直接出现了C#的联机帮助
hwj1107 2009-04-23
  • 打赏
  • 举报
回复
恩,如上,~~~~~~~~~··
学习
himoggy 2009-04-23
  • 打赏
  • 举报
回复
界面上做个按钮 快捷键设为F1
然后直接System.Diagnostics.Process.Start(application.StartupPath+"wode方案.chm");就行
= =不知道有没有拼写错

如果是要制定跳转到某夜那就麻烦些了
一般只要打开文件就行了吧?
himoggy 2009-04-23
  • 打赏
  • 举报
回复
周公 继续kick你贴msdn
周公 2009-04-23
  • 打赏
  • 举报
回复
下面的代码示例显示带有三个按钮的窗体,这些按钮可用于与 mspaint.chm 帮助文件进行交互。“显示帮助索引”按钮显示帮助文件的“索引”选项卡。“显示帮助”按钮根据“帮助导航器”列表中选择的值显示帮助文件的内容。“显示关键字”按钮根据“关键字”文本框中指定的关键字显示帮助文件的内容。

例如,若要按索引值显示 Ovals 帮助页,请在“帮助导航器”下拉列表中选择 HelpNavigator..::.KeywordIndex 值,在“参数”文本框中键入 ovals,然后单击“显示帮助”按钮。若要按关键字显示“使用画笔绘图”帮助主题,请在“关键字”文本框中键入 mspaint.chm::/paint_brush.htm,然后单击“显示关键字”按钮。

该示例使用 ShowHelp 方法显示不同的“帮助”选项卡和“帮助”主题,并用 ShowHelpIndex 方法显示“帮助”索引。


using System;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;

public class Form1 : System.Windows.Forms.Form
{
private const string helpfile = "mspaint.chm";
private System.Windows.Forms.Button showIndex;
private System.Windows.Forms.Button showHelp;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox navigatorCombo;
private System.Windows.Forms.Button showKeyword;
private System.Windows.Forms.TextBox keyword;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox parameterTextBox;

[STAThread]
static void Main()
{
Application.Run(new Form1());
}

public Form1()
{
this.showIndex = new System.Windows.Forms.Button();
this.showHelp = new System.Windows.Forms.Button();
this.navigatorCombo = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.showKeyword = new System.Windows.Forms.Button();
this.keyword = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.parameterTextBox = new System.Windows.Forms.TextBox();

// Help Navigator Label
this.label1.Location = new System.Drawing.Point(112, 64);
this.label1.Size = new System.Drawing.Size(168, 16);
this.label1.Text = "Help Navigator:";

// Keyword Label
this.label2.Location = new System.Drawing.Point(120, 184);
this.label2.Size = new System.Drawing.Size(100, 16);
this.label2.Text = "Keyword:";

// Parameter Label
this.label3.Location = new System.Drawing.Point(112, 120);
this.label3.Size = new System.Drawing.Size(168, 16);
this.label3.Text = "Parameter:";

// Show Index Button
this.showIndex.Location = new System.Drawing.Point(16, 16);
this.showIndex.Size = new System.Drawing.Size(264, 32);
this.showIndex.TabIndex = 0;
this.showIndex.Text = "Show Help Index";
this.showIndex.Click += new System.EventHandler(this.showIndex_Click);

// Show Help Button
this.showHelp.Location = new System.Drawing.Point(16, 80);
this.showHelp.Size = new System.Drawing.Size(80, 80);
this.showHelp.TabIndex = 1;
this.showHelp.Text = "Show Help";
this.showHelp.Click += new System.EventHandler(this.showHelp_Click);

// Show Keyword Button
this.showKeyword.Location = new System.Drawing.Point(16, 192);
this.showKeyword.Size = new System.Drawing.Size(88, 32);
this.showKeyword.TabIndex = 4;
this.showKeyword.Text = "Show Keyword";
this.showKeyword.Click += new System.EventHandler(this.showKeyword_Click);

// Help Navigator ComboBox
this.navigatorCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.navigatorCombo.Location = new System.Drawing.Point(112, 80);
this.navigatorCombo.Size = new System.Drawing.Size(168, 21);
this.navigatorCombo.TabIndex = 2;

// Keyword TextBox
this.keyword.Location = new System.Drawing.Point(120, 200);
this.keyword.Size = new System.Drawing.Size(160, 20);
this.keyword.TabIndex = 5;
this.keyword.Text = "";

// Parameter TextBox
this.parameterTextBox.Location = new System.Drawing.Point(112, 136);
this.parameterTextBox.Size = new System.Drawing.Size(168, 20);
this.parameterTextBox.TabIndex = 8;
this.parameterTextBox.Text = "";

// Set up how the form should be displayed and add the controls to the form.
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.parameterTextBox, this.label3,
this.label2, this.keyword,
this.showKeyword, this.label1,
this.navigatorCombo, this.showHelp,
this.showIndex});
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Text = "Help App";

// Load the various values of the HelpNavigator enumeration
// into the combo box.
TypeConverter converter;
converter = TypeDescriptor.GetConverter(typeof(HelpNavigator));
foreach(object value in converter.GetStandardValues())
{
navigatorCombo.Items.Add(value);
}
}

private void showIndex_Click(object sender, System.EventArgs e)
{
// Display the index for the help file.
Help.ShowHelpIndex(this, helpfile);
}
private void showHelp_Click(object sender, System.EventArgs e)
{
// Display Help using the Help navigator enumeration
// that is selected in the combo box. Some enumeration
// values make use of an extra parameter, which can
// be passed in through the Parameter text box.
HelpNavigator navigator = HelpNavigator.TableOfContents;
if (navigatorCombo.SelectedItem != null)
{
navigator = (HelpNavigator)navigatorCombo.SelectedItem;
}
Help.ShowHelp(this, helpfile, navigator, parameterTextBox.Text);
}
private void showKeyword_Click(object sender, System.EventArgs e)
{
// Display help using the provided keyword.
Help.ShowHelp(this, helpfile, keyword.Text);
}
}
周公 2009-04-23
  • 打赏
  • 举报
回复
用System.Windows.Forms.Help类吧。
无法创建 Help 类的新实例。若要为应用程序提供“帮助”,请调用静态 ShowHelp 和 ShowHelpIndex 方法。

可以使用 Help 以 HTML 帮助的格式显示已编译的帮助文件 (.chm) 或 HTML 文件。已编译的帮助文件在页中提供目录、索引、搜索和关键字链接。快捷方式仅适用于已编译的帮助文件。

可以使用 HTML 帮助 Workshop 生成 HTML 帮助 1.x 文件。有关 HTML 帮助的更多信息,请参见 http://www.microsoft.com/china/msdn 上的 "HTML Help Workshop" 和其他 HTML 帮助主题。
himoggy 2009-04-23
  • 打赏
  • 举报
回复
楼上方法不错
只是这个要自己写代码
ShowHelp(Control, String)
方法4重载
yingzhilian2008 2009-04-23
  • 打赏
  • 举报
回复
Help.ShowHelp(文档路径);
螳螂86 2009-04-23
  • 打赏
  • 举报
回复
himoggy 2009-04-23
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 zhangyanyang 的回复:]
C# code
System.Diagnostics.Process.Start("F:/我的项目/HTML"+"方案文件.chm");



是不是这样?
[/Quote]

如果就放在这个目录里还好,如果是要让别人使用的话,不能保证别人都放在这个目录下吧
所以说个人觉得,把那个文件放在程序运行同文件夹下更方便……

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧