I'm having some trouble to show a tooltip using the mousemove event. Basically, I want to show a tooltip when my mousepointer is over certain regions of a picturebox. I'm trying to accomplish this using the mousemove event, determining wether the pointer is on a sweet spot and (if so) setting the tooltip using settooltip.
this is my mousemove event (as I've noticed that mousemove is continuously triggered when a tooltip is shown, I check if the position really changed or not)
private void pbFaseFlow_MouseMove(object sender, MouseEventArgs e)
{
if (e.Location != OldPosition)
{
OldPosition = e.Location;
// determine text for tooltip (gets loaded into a global string)
DetermineText(Position);
// show the coords and tooltip text for debugging in some textbox
tbInfo.Text = e.X.ToString() + " " + e.Y.ToString() + " " + ToolTipText;
// show tooltip
if (ToolTipText != string.Empty)
{
toolTip.SetToolTip(pbFaseFlow, ToolTipText);
toolTip.Active = true;
}
else
{
toolTip.Active = false;
}
}
}
This is working fine, except for when I move my mouse into a sweet spot for the first pixel. In my textbox, I can see that the text is being determined (say "test" f.e.), but the tooltip does not show. Only after I move my mouse 1 more pixel the tooltip is shown. This is a problem, because on sweetspots can be just 1 pixel wide, so the tooltip doesnt show when moving the mouse over it from left to right (it does show, when moving up/down..)
Even when I'm not checking for a position that has really changed, (I omit the e.location check), the tooltip does not show until I move the mouse 1 more pixel.
I noticed that if I never make the tooltip unactive, it does work, but I don't want anything to show outside the sweetspots..
What is happening here?
---------- edit --------------
Some more information :
When I change the code to this (basically always showing the tooltip, except now only with a single space when there's no information), the tooltip updates immediately over sweet spots. Disadvantage is that I now have an empty tooltip showing all the time when there's no data to show, pretty annoying.
// show tooltip
if (ToolTipText != string.Empty)
{
toolTip.Active = true;
toolTip.SetToolTip(pbFaseFlow, ToolTipText);
}
else
{
toolTip.Active = true;
ToolTipText = " ";
toolTip.SetToolTip(pbFaseFlow, " ");
}
toolTip.SetToolTip(pbFaseFlow, ToolTipText); toolTip.Active = true;- MethodManwinformstag to your post. If this is wrong, please edit the post. - gunr2171