# How do I return values and display in a ToolTipText?

**URL:** <https://forum.kirupa.com/t/how-do-i-return-values-and-display-in-a-tooltiptext/263638>\
**Category:** programming\
**Created:** [June 17, 2008, 8:44pm UTC](https://forum.kirupa.com/t/how-do-i-return-values-and-display-in-a-tooltiptext/263638 "2008-06-17T20:44:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Polaris](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@Polaris](https://forum.kirupa.com/u/Polaris)\
**Post date:** [June 17, 2008, 8:44pm UTC](https://forum.kirupa.com/t/how-do-i-return-values-and-display-in-a-tooltiptext/263638/1 "2008-06-17T20:44:59Z")

</div>

I am doing a project where I have planes scattered on a grid. I need to have a tooltiptext that when the cursor is over the plane icon it will display the ID number, X, Y, and Z coordinates that are being read from a .txt file.

My guess is that I will need a mouse motion listener added and then in the parenthesis of the tooltiptext I’ll be calling getID, getX, getY, and getZ.

---

<div class="post-metadata">

**Author:** ![Templarian](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/templarian/32/7152_2.png) [@Templarian](https://forum.kirupa.com/u/Templarian)\
**Post date:** [June 17, 2008, 9:56pm UTC](https://forum.kirupa.com/t/how-do-i-return-values-and-display-in-a-tooltiptext/263638/2 "2008-06-17T21:56:29Z")

</div>

C# right. There is a MouseEnter and MouseLeave event for all the objects. Use those events and the code below.

To make it show up:

```auto
private ToolTip toolTip = new ToolTip();
string s = "ID: " + id.ToString() + "ect...";
toolTip.Show(s, this, 2000);

```

To make it fade out:

```auto
toolTip.Hide();

```

s \<\< string that will be displayed  
this \<\< is the form  
2000 \<\< Duration (2seconds).

… Do you need the code to read from a text file… just google there are thousand tutorials that can explain it perfectly. If you need to get the values out of the text file show us how you have the text file set up.

---

<div class="post-metadata">

**Author:** ![Polaris](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@Polaris](https://forum.kirupa.com/u/Polaris)\
**Post date:** [June 18, 2008, 12:05am UTC](https://forum.kirupa.com/t/how-do-i-return-values-and-display-in-a-tooltiptext/263638/3 "2008-06-18T00:05:37Z")

</div>

Uh…sorry probably should’ve specified, its JAVA.
