Version 9.1
I'm using a ToolTip to display the full text of a trimmed UltraFormattedLinkLabel in a mock-up application I'm working on. I've used this code before on simpler forms, and it displays correctly. This form, which has a link label in a panel that's docked on the left via an UltraDockManager. In this case, as the attached picture shows, it's way off. Here's the code I'm using:
private void link_MouseHover( object sender, EventArgs e ) { var lbl = (UltraFormattedLinkLabel) sender; var ui = lbl.UIElement.GetDescendant( typeof( FormattedLinkEmbeddableUIElement ) ) as FormattedLinkEmbeddableUIElement; if( ui == null || ui.IsDataFullyVisible ) return; var tt = new ToolTip( lbl ) { DisplayStyle = ToolTipDisplayStyle.BalloonTip, ToolTipText = lbl.Value.ToString( ) }; var loc = this.PointToScreen( lbl.Location ); tt.Show( new Point( loc.X, loc.Y + lbl.Height ) ); }
Is there something I need to do differently here?
My guess here is that the label's Location is based relative to its parent, not the form itself, so you should be using the PointToScreen method on the parent instead of the form.
-Matt
Do you mean this:
var loc = lbl.Parent.PointToScreen( this.Location );
That doesn't work, either, and leads to inconsistent results. When the form is maximized, it shows in approximately the same position as before, but off to the left (I have it maximized on my right-hand monitor). If the form is not maximized, it ends up somewhat near the middle of the form.