Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
2.75/5 (4 votes)
See more:
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
Posted
Updated 28-Sep-16 10:58am

I think this would be the perfect solution for you:

C#
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);
        }


Hope it helps... \m/
 
Share this answer
 
Comments
ridoy 22-Oct-12 12:51pm    
+5
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-.

C#
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);
        }
    }
}
 
Share this answer
 
v2
Use TOOL TIP Property of the button.
 
Share this answer
 
C#
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 WindowsFormsApplication
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            //hover tool notes init
            this.button1.MouseHover += button1_MouseHover;
        }

        private void button1_MouseHover(object sender, EventArgs e)
        {
            System.Windows.Forms.ToolTip ToolTip1 = new System.Windows.Forms.ToolTip();
            ToolTip1.SetToolTip(this.button1, "Note Goes Here");
        }
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900