using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace WindowsFormsHelpProvider { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { //获取htm帮助文件的位置 string strPath = Application.StartupPath.Substring(0, Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf("\\")).LastIndexOf("\\")); strPath += @"\helpPage.htm"; //设置helpProvider1的HelpNamespace属性为帮助文件的路径 helpProvider1.HelpNamespace = strPath; MessageBox.Show(strPath); //通过SetShowHelp设置是否显示帮助信息 helpProvider1.SetShowHelp(this, true); } } }