C# WinForms: Trouble getting tooltip near mouse coordinate

Posted on 2012-08-15
Medium Priority
Last Modified: 2012-08-15
I have a DataGridView and need to show a tool tip at the cursor displaying the full contents of the entire row.  But this call seems to fail:

            this.addSpecialtyToolTip.Show("Test tip", myDataGridView, 0, 0);

However, this one works:

            this.addSpecialtyToolTip.Show("Test tip", myOkButton, 0, 0);

But I do not want the tool tip over the OK button.

I did not the DataGridView has a bool property "ShowCellToolTips", but when I call

myDataGridView.ShowCellToolTips = true, nothing displays.

Any ideas what I am missing?
Question by:newbieweb
  • 2
  • 2
LVL 35

Accepted Solution

Robert Schutt earned 2000 total points
ID: 38296364
If you have ShowCellToolTips = true, then an 'internal' tooltip is shown when a cell value is too long to display. Set it to false and you can set individual tooltips like this:
this.myDataGridView.Rows[0].Cells[0].ToolTipText = "Test tip cell";

Open in new window

LVL 35

Assisted Solution

by:Robert Schutt
Robert Schutt earned 2000 total points
ID: 38296373
Sorry, got that mixed up, ShowCellToolTips = true shows cell tooltips (duh). But by default will only show the full value if it's too long to show in the cell as it is. So use the cell tooltip for that. Otherwise, to use your own tooltip, you need to set ShowCellToolTips = false.

Author Comment

ID: 38297163
Mine will always be lober than an individual cell's width.  But your code does not work.  I did the following:

myDataGridView.ShowCellToolTips = true;
myDataGridView.Rows[0].Cells[0].ToolTipText = "Test cell tip";

What am I missing?

Author Closing Comment

ID: 38297228
Got it working as you described.  Thanks.

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question