Show a tooltip programmatically

  • Thread starter Thread starter Paul E Collins
  • Start date Start date
P

Paul E Collins

How can I show a tooltip programmatically? I want to make it appear
over a particular control at the specific time I choose, and not rely
on the user's mouse movements. I don't mind using some Windows API
call for this, if somebody can explain the parameters.

Eq.
 
You don't need Windows API to do this at all. Use the ToolTip class.

public class blah : System.Windows.Forms.Control
{
private System.Windows.Forms.ToolTip toolTip;

protected int _ToolTipInterval = 3000;
public virtual int ToolTipInterval
{
get { return _ToolTipInterval; }
set { _ToolTipInterval = value; }
}

public string ToolTipText
{
get { return "TooTip"; }
}

protected override void OnMouseHover(EventArgs e)
{
base.OnMouseHover(e);
toolTip.Show("ZIndex: " + this.ZIndex.ToString(),
this, 5, 5, ToolTipInterval);
}

public blah()
{
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.toolTip.AutoPopDelay = 5000;
this.toolTip.InitialDelay = 250;
this.toolTip.ReshowDelay = 50;
this.toolTip.ShowAlways = true;
}

}

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.
 
Kevin said:
[... sample code ...]
toolTip.Show("ZIndex: " + this.ZIndex.ToString(),
this, 5, 5, ToolTipInterval);

Sorry - I forgot to mention that I need this to work in .NET Framework
1.1, which (unlike 2.0) doesn't have the static ToolTip.Show method.
Any other suggestion?

Eq.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top