Go homepage(回首页) Upload pictures (上传图片) Write articles (发文字帖)
The author:(作者)qqpublished in(发表于) 2014/7/11 9:17:03 C#中HelpProvider组件应用实例
C#中HelpProvider组件应用实例
HelpProvider组件1.功能HelpProvider组件的功能如下所示。HelpProvider组件用于将HTML帮助、1.x帮助文件(.htm文件或由HTML Help Workshop产生的 chm文件)与Windows应用程序相关联。可以通过多种方式提供帮助,例如,为Windows窗体中的控件提供区分上下文的帮助。为特定对话框或对话框中的特定控件提供区分上下文的帮助。打开帮助文件到特定部分,如目录、索引或搜索功能的主页。图1所示为HelpProvider组件。图1 HelpProvider组件2.属性(1)Tag属性。该属性获取或设置包含有关 HelpProvider的补充数据的对象。(2)HelpNamespace属性。该属性用于获取或设置一个值,该值指定与此HelpProvider对象关联的帮助文件名。语法: public virtual string HelpNamespace { get; set; }]属性值:帮助文件的名称,其形式可以是“C:pathsample.chm”或“/folder/file.htm”。示例HelpNamespace属性的使用程序主要代码如下: string strPath = Application.StartupPath.Substring(0, Application.StartupPath.Substring(0,Application.StartupPath.LastIndexOf("")).LastIndexOf(""));strPath += @"sl830F1.html";this.helpProvider1.HelpNamespace = strPath;完整程序代码如下:★★★★★主程序文件完整程序代码★★★★★ using System;using System.Collections.Generic;using System.Windows.Forms;namespace _8_30{static class Program{/// /// 应用程序的主入口点。/// [STAThread]static void Main(){Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);Application.Run(new frmHelpProvider());}}}★★★★frmHelpProvider窗体设计文件完整程序代码★★★★★ using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace _8_30{public partial class frmHelpProvider : Form{public frmHelpProvider(){InitializeComponent();}private void button2_Click(object sender, EventArgs e){}private void button3_Click(object sender, EventArgs e){}private void frmHelpProvider_Load(object sender, EventArgs e){string strPath = Application.StartupPath.Substring(0, Application.StartupPath.Substring(0,Application.StartupPath.LastIndexOf("")).LastIndexOf(""));strPath += @"F1.html";this.helpProvider1.HelpNamespace = strPath;}private void button1_Click(object sender, EventArgs e){}}}★★★★★frmHelpProvider窗体代码文件完整程序代码★★★★★
赞