C# WinForms: Trouble getting tooltip near mouse coordinate

Posted on 2012-08-15
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
    LVL 35

    Accepted Solution

    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
    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

    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

    Got it working as you described.  Thanks.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    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.…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    731 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now