Sarmad Asif
Sarmad Asif

Reputation: 89

How to set tooltip position just beneath the cursor?

I want to show the tooltip just beneath the cursor position, and not in its default position (its show the tooltip behind the cursor). How can I set its position?

I did nothing, but added a tooltip in the form and wrote the following code to display it on button hover:

toolTip1.Show("Text", button1);

Upvotes: 1

Views: 1860

Answers (1)

Asad Ali
Asad Ali

Reputation: 684

Use this overload of the ToolTip.Show() method:

public void Show(
    string text,
    IWin32Window window,
    Point point
)

Your code then becomes:

Point pos = new Point(Cursor.Position.X, Cursor.Position.Y - 1); //Change this to whatever you want
toolTip1.Show("Text", button1, pos);

Upvotes: 4

Related Questions