LazarusG
LazarusG

Reputation: 150

Tooltip positioning C#

I have a picturebox that has a mousehover event to show a tooltip based on the status of a service. This seems to be working, but it kind of just pops up where the mouse is and sometimes under the mouse, in the middle of the picture, which doesn't look right. I was reading http://msdn.microsoft.com/en-us/library/windows/desktop/aa511495.aspx#infotipsgl and it suggested to have the tooltip moved off to the side. This would be great, but I can't figure out how to move it.

ToolTip on toolTip1 is blank and on the mouseHover event I have tried using

toolTip.SetToolTip(this.pictureBox1, "Message text.");

and

toolTip.Show("Message text.", pictureBox1);

Thanks

Upvotes: 1

Views: 9775

Answers (2)

ygssoni
ygssoni

Reputation: 7349

ToolTip tooltip = new ToolTip();
tooltip.Placement = PlacementMode.Right;
tooltip.PlacementRectangle = new Rect(50, 0, 0, 0);
tooltip.HorizontalOffset = 10;
tooltip.VerticalOffset = 20;

See Here for more details.

Upvotes: 5

Rafal
Rafal

Reputation: 12619

For windows forms you can use this overload of Show method. It allows you to set position offset relative to control that has tool tip.

In wpf as Ravi Patel has already pointed you to article simply us:

<ToolTip HorizontalOffset="10" 
               VerticalOffset="20" .../>

Upvotes: 0

Related Questions