melodiesoflife
asked on
Tooltip tricks
Hi all.
I have a panel on my form. On the panel, I draw many object like: circle, rectangle, elip ...
I have all information about the co-ordinate of these figures.
Now when I move the mouse over these figure, I want it will show a tooltip, depend on with firgure the mouse over.
Example, when mouse over a circle, tooltip text should be "Circle",
When mouse over a rectangle, tooltip text should be "rectangle"
Have you got any idea or any link about this?
I have a panel on my form. On the panel, I draw many object like: circle, rectangle, elip ...
I have all information about the co-ordinate of these figures.
Now when I move the mouse over these figure, I want it will show a tooltip, depend on with firgure the mouse over.
Example, when mouse over a circle, tooltip text should be "Circle",
When mouse over a rectangle, tooltip text should be "rectangle"
Have you got any idea or any link about this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks itsvtk
But I hope a real tooltip. I don't want my tooltip display immediately, I want my tooltip display when my mouse over on the figure for a second (hover event).
Any idea
But I hope a real tooltip. I don't want my tooltip display immediately, I want my tooltip display when my mouse over on the figure for a second (hover event).
Any idea
then try this
public void mycircle(object s, MouseEventArgs e)
{
if( e.X >= 100 && e.X <= 300 && e.Y >= 100 && e.Y <= 300 )
{
toolTip1.SetToolTip( this, "MyCircle" );
}else
{
toolTip1.SetToolTip( this, "" );
}
}
public void mycircle(object s, MouseEventArgs e)
{
if( e.X >= 100 && e.X <= 300 && e.Y >= 100 && e.Y <= 300 )
{
toolTip1.SetToolTip( this, "MyCircle" );
}else
{
toolTip1.SetToolTip( this, "" );
}
}
in form mouse event hadler, you have to compare the current mouse coordinates with the circle or rectanle coordinates. if mouse is in objects, you can re-set the tooltip test....... here is the sample code..... how to reset the tooltip test according to current mouse coordinats..
==========================
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace TOOLTIP
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.ToolT
private System.ComponentModel.ICon
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Cont
this.toolTip1 = new System.Windows.Forms.ToolT
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Name = "Form1";
this.Text = "Form1";
this.toolTip1.SetToolTip(t
this.Load += new System.EventHandler(this.F
this.MouseMove += new System.Windows.Forms.Mouse
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
}
private void Form1_mouse(object sender, System.Windows.Forms.Mouse
{
//MessageBox.Show(this, e.X.ToString(), "Show");
//MessageBox.Show(this, e.Y.ToString(), "Hi");
if( e.X > 200 && e.Y > 200 )
this.toolTip1.SetToolTip(t
}
}
}
==========================
i am changing the tooltip text when mouse x, y co-ordinates are > 200.
itsvtk