简体   繁体   English

根据鼠标指针所在的位置显示文本的控件

[英]Control to show text based on where mouse pointer is

How do i get this? 我怎么得到这个? Which control shows some text when i keep the mouse cursor there for a while? 当我将鼠标指针停留一段时间后,哪个控件显示一些文本?

在此输入图像描述

Edit: I have a timeline in my program. 编辑:我的程序中有一个时间表。 I want the tooltip to show the time value in milliseconds at the point where the mouse cursor is... Is it possible to have a flexible tooltip over a control? 我希望工具提示在鼠标光标所在的点显示时间值(以毫秒为单位)。是否可以在控件上使用灵活的工具提示?

You are asking for the ToolTip control. 您要使用ToolTip控件。


Refer to the following: 请参阅以下内容:

Tooltip in C# C#中的工具提示

普通工具提示

气球工具提示

ToolTip is the magic word. ToolTip是神奇的词。 Have a look at the docs . 看一下文档

I think this is what you're looking for 我认为这就是您要寻找的

How To Add ToolTips To Controls On A Windows Form 如何在Windows窗体上的控件中添加工具提示

if you want to display some text over the print button named "printBtn", Then add the event mouse hover as below 如果要在名为“ printBtn”的打印按钮上显示一些文本,请按如下所示添加事件鼠标悬停

printBtn.MouseHover += new EventHandler(printBtn_MouseHover);

Then, use the following code to display the text when the mouse is over the print button 然后,当鼠标悬停在“打印”按钮上时,使用以下代码显示文本

void printBtn_MouseHover(object sender, EventArgs e)
{
   ToolTip tip = new ToolTip();
   tip.SetToolTip(printBtn, "Click to print");
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM