很多开发工具尤其是微软的vs,如在vc#的winform里,看看这个:
===========================
Form.HelpButton 属性 [C#]请参见
Form 类 | Form 成员 | System.Windows.Forms 命名空间
要求
平台: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows .NET Server family
语言
C#[C#]
public bool HelpButton {get; set;}属性值
如果为 true,则在窗体的标题栏中显示“帮助”按钮;否则,为 false。默认值为 false。备注
当此属性设置为 true 时,在“关闭”按钮左侧的标题栏中出现一个带问号的小按钮。可以使用此按钮显示应用程序的帮助。可以为 Control 类的 HelpRequested 事件创建事件处理程序,以便在用户单击该窗体的“帮助”按钮时向用户显示“帮助”信息。如果显示最大化或最小化框,则忽略 HelpButton 属性的值。示例
[Visual Basic, C#] 下面的示例创建 Form 的一个新实例,并调用 ShowDialog 方法将窗体显示为对话框。该示例设置 FormBorderStyle、AcceptButton、CancelButton、MinimizeBox、MaximizeBox 和 StartPosition 属性,将窗体的外观和功能更改为对话框形式。该示例还使用窗体的 Controls 集合的 Add 方法来添加两个 Button 控件。该示例使用 HelpButton 属性在对话框的标题栏中显示“帮助”按钮。[Visual Basic]
Public Sub CreateMyForm()
' Create a new instance of the form.
Dim form1 As New Form()
' Create two buttons to use as the accept and cancel buttons.
Dim button1 As New Button()
Dim button2 As New Button()
' Set the text of button1 to "OK".
button1.Text = "OK"
' Set the position of the button on the form.
button1.Location = New Point(10, 10)
' Set the text of button2 to "Cancel".
button2.Text = "Cancel"
' Set the position of the button based on the location of button1.
button2.Location = _
New Point(button1.Left, button1.Height + button1.Top + 10)
' Set the caption bar text of the form.
form1.Text = "My Dialog Box"
' Display a help button on the form.
form1.HelpButton = True
' Define the border style of the form to a dialog box.
form1.FormBorderStyle = FormBorderStyle.FixedDialog
' Set the MaximizeBox to false to remove the maximize box.
form1.MaximizeBox = False
' Set the MinimizeBox to false to remove the minimize box.
form1.MinimizeBox = False
' Set the accept button of the form to button1.
form1.AcceptButton = button1
' Set the cancel button of the form to button2.
form1.CancelButton = button2
' Set the start position of the form to the center of the screen.
form1.StartPosition = FormStartPosition.CenterScreen
' Add button1 to the form.
form1.Controls.Add(button1)
' Add button2 to the form.
form1.Controls.Add(button2)
' Display the form as a modal dialog box.
form1.ShowDialog()
End Sub
[C#]
public void CreateMyForm()
{
// Create a new instance of the form.
Form form1 = new Form();
// Create two buttons to use as the accept and cancel buttons.
Button button1 = new Button ();
Button button2 = new Button ();
// Set the text of button1 to "OK".
button1.Text = "OK";
// Set the position of the button on the form.
button1.Location = new Point (10, 10);
// Set the text of button2 to "Cancel".
button2.Text = "Cancel";
// Set the position of the button based on the location of button1.
button2.Location
= new Point (button1.Left, button1.Height + button1.Top + 10);
// Set the caption bar text of the form.
form1.Text = "My Dialog Box";
// Display a help button on the form.
form1.HelpButton = true; // Define the border style of the form to a dialog box.
form1.FormBorderStyle = FormBorderStyle.FixedDialog;
// Set the MaximizeBox to false to remove the maximize box.
form1.MaximizeBox = false;
// Set the MinimizeBox to false to remove the minimize box.
form1.MinimizeBox = false;
// Set the accept button of the form to button1.
form1.AcceptButton = button1;
// Set the cancel button of the form to button2.
form1.CancelButton = button2;
// Set the start position of the form to the center of the screen.
form1.StartPosition = FormStartPosition.CenterScreen;
// Add button1 to the form.
form1.Controls.Add(button1);
// Add button2 to the form.
form1.Controls.Add(button2);
// Display the form as a modal dialog box.
form1.ShowDialog();
}
===========================
Form.HelpButton 属性 [C#]请参见
Form 类 | Form 成员 | System.Windows.Forms 命名空间
要求
平台: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows .NET Server family
语言
C#[C#]
public bool HelpButton {get; set;}属性值
如果为 true,则在窗体的标题栏中显示“帮助”按钮;否则,为 false。默认值为 false。备注
当此属性设置为 true 时,在“关闭”按钮左侧的标题栏中出现一个带问号的小按钮。可以使用此按钮显示应用程序的帮助。可以为 Control 类的 HelpRequested 事件创建事件处理程序,以便在用户单击该窗体的“帮助”按钮时向用户显示“帮助”信息。如果显示最大化或最小化框,则忽略 HelpButton 属性的值。示例
[Visual Basic, C#] 下面的示例创建 Form 的一个新实例,并调用 ShowDialog 方法将窗体显示为对话框。该示例设置 FormBorderStyle、AcceptButton、CancelButton、MinimizeBox、MaximizeBox 和 StartPosition 属性,将窗体的外观和功能更改为对话框形式。该示例还使用窗体的 Controls 集合的 Add 方法来添加两个 Button 控件。该示例使用 HelpButton 属性在对话框的标题栏中显示“帮助”按钮。[Visual Basic]
Public Sub CreateMyForm()
' Create a new instance of the form.
Dim form1 As New Form()
' Create two buttons to use as the accept and cancel buttons.
Dim button1 As New Button()
Dim button2 As New Button()
' Set the text of button1 to "OK".
button1.Text = "OK"
' Set the position of the button on the form.
button1.Location = New Point(10, 10)
' Set the text of button2 to "Cancel".
button2.Text = "Cancel"
' Set the position of the button based on the location of button1.
button2.Location = _
New Point(button1.Left, button1.Height + button1.Top + 10)
' Set the caption bar text of the form.
form1.Text = "My Dialog Box"
' Display a help button on the form.
form1.HelpButton = True
' Define the border style of the form to a dialog box.
form1.FormBorderStyle = FormBorderStyle.FixedDialog
' Set the MaximizeBox to false to remove the maximize box.
form1.MaximizeBox = False
' Set the MinimizeBox to false to remove the minimize box.
form1.MinimizeBox = False
' Set the accept button of the form to button1.
form1.AcceptButton = button1
' Set the cancel button of the form to button2.
form1.CancelButton = button2
' Set the start position of the form to the center of the screen.
form1.StartPosition = FormStartPosition.CenterScreen
' Add button1 to the form.
form1.Controls.Add(button1)
' Add button2 to the form.
form1.Controls.Add(button2)
' Display the form as a modal dialog box.
form1.ShowDialog()
End Sub
[C#]
public void CreateMyForm()
{
// Create a new instance of the form.
Form form1 = new Form();
// Create two buttons to use as the accept and cancel buttons.
Button button1 = new Button ();
Button button2 = new Button ();
// Set the text of button1 to "OK".
button1.Text = "OK";
// Set the position of the button on the form.
button1.Location = new Point (10, 10);
// Set the text of button2 to "Cancel".
button2.Text = "Cancel";
// Set the position of the button based on the location of button1.
button2.Location
= new Point (button1.Left, button1.Height + button1.Top + 10);
// Set the caption bar text of the form.
form1.Text = "My Dialog Box";
// Display a help button on the form.
form1.HelpButton = true; // Define the border style of the form to a dialog box.
form1.FormBorderStyle = FormBorderStyle.FixedDialog;
// Set the MaximizeBox to false to remove the maximize box.
form1.MaximizeBox = false;
// Set the MinimizeBox to false to remove the minimize box.
form1.MinimizeBox = false;
// Set the accept button of the form to button1.
form1.AcceptButton = button1;
// Set the cancel button of the form to button2.
form1.CancelButton = button2;
// Set the start position of the form to the center of the screen.
form1.StartPosition = FormStartPosition.CenterScreen;
// Add button1 to the form.
form1.Controls.Add(button1);
// Add button2 to the form.
form1.Controls.Add(button2);
// Display the form as a modal dialog box.
form1.ShowDialog();
}
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;namespace WindowsApplication7
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.ToolBar toolBar1;
private System.Windows.Forms.ToolBarButton toolBarButton1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.toolBar1 = new System.Windows.Forms.ToolBar();
this.toolBarButton1 = new System.Windows.Forms.ToolBarButton();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(104, 200);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// toolBar1
//
this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
this.toolBarButton1});
this.toolBar1.DropDownArrows = true;
this.toolBar1.Name = "toolBar1";
this.toolBar1.ShowToolTips = true;
this.toolBar1.Size = new System.Drawing.Size(292, 38);
this.toolBar1.TabIndex = 1;
this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
//
// toolBarButton1
//
this.toolBarButton1.Text = "?";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.toolBar1,
this.button1});
this.HelpButton = true;
this.Name = "Form1";
this.Text = "Form1";
this.Click += new System.EventHandler(this.Form1_Click);
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false); }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
} private void Form1_Load(object sender, System.EventArgs e)
{
}
private void button1_Click(object sender, System.EventArgs e)
{
if(this.Cursor == Cursors.Help)
{
this.Cursor=Cursors.Default;
//当然这里应该改成显示世纪的上下文帮助文件
MessageBox.Show("在线帮助:\n\n这是一个按钮,单击它就会打开一个新窗口...");
}
else
{
//作正常情况下该做的事。
MessageBox.Show("哈哈,你单击了我!");
}
} private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
this.Cursor = Cursors.Help;
} private void Form1_Click(object sender, System.EventArgs e)
{
this.Cursor=Cursors.Default;
} }
}