使用 Windows 窗体在按钮上显示工具提示 [英] Display a tooltip over a button using Windows Forms

查看:28
本文介绍了使用 Windows 窗体在按钮上显示工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 Windows 窗体在按钮上显示工具提示?

How can I display a tooltip over a button using Windows Forms?

推荐答案

ToolTip 是一个单个 WinForms 控件,用于处理在单个表单上显示多个 元素的工具提示.

The ToolTip is a single WinForms control that handles displaying tool tips for multiple elements on a single form.

假设您的按钮名为 MyButton.

Say your button is called MyButton.

  1. 添加 ToolTip 控件(在 CommonWindows 窗体中的控件工具箱)添加到您的表单中.
  2. 给它一个名称 - 说 MyToolTip
  3. 设置MyToolTip 上的工具提示";MyButton 的属性(在 Misc 下按钮属性网格)到当您将鼠标悬停在它上面时应显示的文本.

当光标悬停在按钮上时,工具提示会自动出现,但如果需要以编程方式显示,请调用

The tooltip will automatically appear when the cursor hovers over the button, but if you need to display it programmatically, call

MyToolTip.Show("Tooltip text goes here", MyButton);

在您的代码中显示工具提示,以及

in your code to show the tooltip, and

MyToolTip.Hide(MyButton);

让它再次消失.

这篇关于使用 Windows 窗体在按钮上显示工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆