共用方式為


如何:在設計階段為 Windows Form 上的控制項設定工具提示

您可以在程式碼或 Visual Studio 的 Windows Forms 設計工具中設定 ToolTip 字串。 如需元件的詳細資訊 ToolTip ,請參閱 工具提示元件概觀

以程式設計方式設定工具提示

  1. 新增將顯示工具提示的控制項。

  2. SetToolTip使用 元件的 方法 ToolTip

    ' In this example, Button1 is the control to display the ToolTip.
    ToolTip1.SetToolTip(Button1, "Save changes")
    
    // In this example, button1 is the control to display the ToolTip.
    toolTip1.SetToolTip(button1, "Save changes");
    
    // In this example, button1 is the control to display the ToolTip.
    toolTip1->SetToolTip(button1, "Save changes");
    

在設計工具中設定工具提示

  1. 在 Visual Studio 中,將元件新增 ToolTip 至表單。

  2. 選取將顯示工具提示的控制項,或將它新增至表單。

  3. 在 [ 屬性] 視窗中,將 ToolTip1 值上的 ToolTip 設定 為適當的文字字串。

以程式設計方式移除工具提示

  1. SetToolTip使用 元件的 方法 ToolTip

    ' In this example, Button1 is the control displaying the ToolTip.
    ToolTip1.SetToolTip(Button1, Nothing)
    
    // In this example, button1 is the control displaying the ToolTip.
    toolTip1.SetToolTip(button1, null);
    
    // In this example, button1 is the control displaying the ToolTip.
    toolTip1->SetToolTip(button1, NULL);
    

移除設計工具中的工具提示

  1. 在 Visual Studio 中,選取顯示工具提示的控制項。

  2. 在 [ 屬性] 視窗中,刪除 ToolTip1 工具提示中的 文字。

另請參閱