I have a custom control (C#, visual studio). I want to show a tooltip on the mousehover event.
However, no matter what I do, it either never shows or has a chance of showing multiple times.
I thought it would be as simple as:
private void MyControl_MouseHover(object sender, EventArgs e)
{
ToolTip tT = new ToolTip();
tT.Show("Why So Many Times?", this);
}
But this does not work. I have tried a bunch of things but cannot seem to get it to work. I would like to have the tooltip be part of the component because I want to access private fields from it for display.
Thanks for any help
Have you tried instantiating the tooltip in your constructor and showing it on the mouse hover?
public ToolTip tT { get; set; }
public ClassConstructor()
{
tT = new ToolTip();
}
private void MyControl_MouseHover(object sender, EventArgs e)
{
tT.Show("Why So Many Times?", this);
}
The MouseHover is fired every time the mouse moves over your control. So your are creating a new tooltip every single time the event is fired. That's why you see multiple instances of this widget. Try the Joseph's answer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With