开发者

Display a tool tip on current document

I am developing a code edit开发者_StackOverflowor like VS. I want to display a tool tip window when mouse cursor lands on a text. The ToolTip.Show() method asks for a IWin32Window parameter...

Please tell me how to display the tool tip in the current document just as Visual Studio Intellisense works.


The ToolTip.Show method also has other more appropriate overloads, like this one.

You can pass the edit control (that is, your text box) that you want to be associated with the tooltip as the IWin32Window parameter.

Then, you can specify the current coordinates of the mouse cursor as the X and Y arguments:

  • If you're trying to show this tooltip in one of the mouse event handlers (like MouseMove), the current coordinates of the mouse cursor are passed in as part of the MouseEventArgs—just use the e.X and e.Y properties.

  • Otherwise, you'll need to use the Control.MousePosition property to get its current location, which will return a Point representing its current location relative to screen coordinates. Another one of the overloads to the ToolTip.Show method accepts a Point parameter that you can use here instead of separate X and Y coordinates


ToolTip.Show Method (String, IWin32Window)

The second argument is the control for which the tool tip is to be shown.

toolTip1.Show("Test 123", button1, Int32.MaxValue); 

Visual Studio tracks the word underneath the mouse and displays tooltips/intellisense accordingly. One way for you to do the same could be to:

  1. Track the mouse movements
  2. Get the text under mouse
  3. Show tooltip.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜