可以在代码或 Visual Studio 的 Windows 窗体设计器中设置 ToolTip 字符串。 有关 ToolTip 组件的详细信息,请参阅 工具提示组件概述。
以编程方式设置 ToolTip
添加将显示 ToolTip 的控件。
使用 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");
在设计器中设置 ToolTip
在 Visual Studio 中,向窗体添加 ToolTip 组件。
选择将显示 ToolTip 的控件,或将它添加到窗体。
在 属性 窗口中,将工具提示1 上的 工具提示 值设置为适当的文本字符串。
以编程方式删除 ToolTip
使用 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);
在设计器中删除 ToolTip
在 Visual Studio 中,选择正在显示 ToolTip 的控件。
在属性窗口中,删除“ToolTip1 上的 ToolTip”中的文本。