c#Buttons:鼠标悬停在按钮上时显示消息 [英] c# Buttons: Show Message when mouse hovers over the button

查看:916
本文介绍了c#Buttons:鼠标悬停在按钮上时显示消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我想在c#User Control中创建一个按钮(上面有图像)。当用户将鼠标悬停在按钮上并在那里停留一秒钟时,我希望弹出一个小小的消息\dialog \这样的东西弹出并用2个字描述按钮是什么。 (例如,它将为编辑文本按钮编写编辑)。



当用户从此按钮移动鼠标时,我希望此消息消失。



我该怎么办?



谢谢

Hello,

I would like to create a button (with an image on it) in c# User Control. When a user hovers with the mouse over the button, and stays there for a second, I would like a small message\dialog\something like this to pop up and describe in 2 words what the button is. (For example, it will write "edit" for an Edit Text button).

When the user moves the mouse from this button, I want this message to disappear.

How can I do it?

Thanks

推荐答案

我认为这对你来说是完美的解决方案:



I think this would be the perfect solution for you:

private void ButtonName_MouseHover(object sender, EventArgs e)
        {
            System.Windows.Forms.ToolTip ToolTip1 = new System.Windows.Forms.ToolTip();
            ToolTip1.SetToolTip(this.button1, this.button1.Text);
        }





希望它有所帮助... \m /



Hope it helps... \m/


<大> 1。 添加图片到按钮的 BackgroundImage 属性。



2。 在按钮上添加工具提示

3。 找到属性'ToolTip on toolTip1'(如果你更改了它的默认名称,名称可能不是toolTip1)。现在写工具提示按钮的属性。



现在,如果你想手动使用它,请将其作为 -



1. Add image to BackgroundImage property of button.

2. Add a tooltip to the button.
3. Find the property 'ToolTip on toolTip1' (the name may not be toolTip1 if you changed it's default name).Now write "Edit"(as according to your requirement or anything you write will be popped out) on the tooltip property of button.

Now if you want this manually use this as under-.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication29
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        ToolTip t1 = new ToolTip();
        private void button1_MouseHover(object sender, EventArgs e)
        {
            t1.Show("Edit",button1);
        }
    }
}


使用按钮的工具提示属性。
Use TOOL TIP Property of the button.


这篇关于c#Buttons:鼠标悬停在按钮上时显示消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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