如何将工具提示添加到控件? [英] How do I add a ToolTip to a control?

查看:100
本文介绍了如何将工具提示添加到控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些控件,当鼠标悬停在其上时,我想显示一个 ToolTip 。我怎样才能做到这一点?我想知道如何在代码中以及在设计器中正确地做到这一点(工具箱中有一个 ToolTip 组件,但我不太了解。

I have some controls that I would like to display a ToolTip for when the mouse is hovering over it. How can I do this? I would like to know how to do this properly in code, but also in the designer (There is a ToolTip component in the toolbox, but I don't quite.. get it).

如果这是重复的,我不会感到惊讶,但是我只能找到在更高级的特定场景下遇到的问题。我想了解基本知识。

推荐答案

此处是您使用代码进行此操作的文章

Here is your article for doing it with code

private void Form1_Load(object sender, System.EventArgs e)
{
     // Create the ToolTip and associate with the Form container.
     ToolTip toolTip1 = new ToolTip();

     // Set up the delays for the ToolTip.
     toolTip1.AutoPopDelay = 5000;
     toolTip1.InitialDelay = 1000;
     toolTip1.ReshowDelay = 500;
     // Force the ToolTip text to be displayed whether or not the form is active.
     toolTip1.ShowAlways = true;

     // Set up the ToolTip text for the Button and Checkbox.
     toolTip1.SetToolTip(this.button1, "My button1");
     toolTip1.SetToolTip(this.checkBox1, "My checkBox1");
}

这篇关于如何将工具提示添加到控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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