views:

441

answers:

3

I'm using the CellToolTipTextNeeded event of a DataGridView, and the tooltip is being shown under the mouse. I can get the ToolTip object out via reflection, but I don't have any control over where it's positioned since I'm not the one calling Show(). How do I move a tooltip?

+1  A: 

How about a custom one?

+1  A: 

I think the short answer is: you can't, not yet anyway. I would probably think about building a custom one like 'unknown (yahoo)' suggested.

Cory Larson
+1  A: 

You'll have to control the tooltip yourself using the Show and Hide methods if you want any control over how and where it is positioned using the 2.0 framework unless you want to get into Window's API calls.

Unfortunately, it looks like the tooltip position is set very, very early on in its creation. The tooltip only has 3 events to handle, and we aren't very interested in Dispose in this case.

The Draw event is fired after the Popup event and it seems as if the position has already been set as the Bounds property in the PopupEventArgs is readonly.

Here's a link to one of many articles (at the time of this post) on creating a custom control: http://andrusdevelopment.blogspot.com/2007/10/implementing-custom-tooltip-in-c.html

And the MSDN documentation on using the tooltip's Show and Hide methods is actually fairly decent: http://msdn.microsoft.com/en-us/library/44atyhsa(VS.80,printer).aspx

Sorry, but it just doesn't look like there is a quick and easy answer to this one. Hopefully someone will prove me wrong for both are sakes.

Scott

codefoo