Howdy,
I'm trying to only show a tooltip when someone is hovering over the UltraGrid caption.
I've tried disabling the UItraToolTipManager in the hover, if it's not over the right UIElement but that's not working.
Here's my code:
private void ugAlerts_MouseHover(object sender, EventArgs e) { ultraToolTipManager1.Enabled = false; Point clientPt = ugAlerts.PointToClient(Cursor.Position); Object obj = ugAlerts.DisplayLayout.UIElement.ElementFromPoint(clientPt); if (obj.GetType() == typeof(Infragistics.Win.TextUIElement)) { Infragistics.Win.TextUIElement tuie = obj as Infragistics.Win.TextUIElement; if (tuie.Parent.GetType() == typeof(Infragistics.Win.UltraWinGrid.CaptionAreaUIElement)) { ultraToolTipManager1.Enabled = true; } } }
I really thinking I'm missing something simple....
Any guidance?
thanks!
Hi,
You can't really use MouseHover to control tooltips, because MouseHover deals with the entire control. So, for example, if you hover the mouse over any part of the grid and the MouseHover event fires, then you move the mouse over some other part of the grid, the MouseHover event will not fire again. It only fires again if the mouse leaves the control and comes back in.
If you want to change the tooltip on the grid based on the location of the mouse, then I recommend using the MouseMove event.
By the way... I could be wrong, but I think the event args for MouseHover are in client coords, so you don't need to use PointToClient. In any case, I am certain this is true for MouseMove.
Thanks Mike, I still can't get it to work...am I missing something?
private void ugAlerts_MouseMove(object sender, MouseEventArgs e) { Object obj = ugAlerts.DisplayLayout.UIElement.ElementFromPoint(e.Location); if (obj.GetType() != typeof(Infragistics.Win.TextUIElement)) { uttmTips.HideToolTip(); return; } Infragistics.Win.TextUIElement tuie = obj as Infragistics.Win.TextUIElement; if (tuie.Parent.GetType() != typeof(Infragistics.Win.UltraWinGrid.CaptionAreaUIElement)) { uttmTips.HideToolTip(); return; } Control o = sender as Control; UltraToolTipInfo toolTipInfo = new UltraToolTipInfo("Hello", ToolTipImage.Info, "Comment:", DefaultableBoolean.True); toolTipInfo.Appearance.BackColor = Color.White; toolTipInfo.Appearance.BackColor2 = Color.Cornsilk; toolTipInfo.Appearance.BackGradientStyle = GradientStyle.Elliptical; toolTipInfo.Appearance.ForeColor = Color.Black; uttmTips.AutoPopDelay = 0; uttmTips.SetUltraToolTip(o, toolTipInfo); uttmTips.ShowToolTip(o); }
I tried out some code similar to yours and I had a lot of trouble getting this working, too. But I finally figured it out.
The problem is the call to ShowToolTip. Since you are setting the AutoPopDelay to 0 - the tooltip will show up immediately anyway, so calling ShowToolTip is unnecessary.
The reason is causes a problem is that when you call ShowToolTip, the tooltip displays under the mouse. Since a new Window appearance under the mouse, this is essentially as though the mouse was moved off of the grid, so the MouseMove event of the grid fires and your code hides the tooltip - since the mouse is no longer over the caption.
Anyway, just removing the call to ShowToolTip should fix it. Here's the code that I used which works:
private void ultraGrid1_MouseMove(object sender, MouseEventArgs e) { UltraGrid grid = (UltraGrid)sender; UIElement element = grid.DisplayLayout.UIElement.LastElementEntered; if (element != null) { CaptionAreaUIElement captionAreaUIElement = element as CaptionAreaUIElement; if (captionAreaUIElement == null) captionAreaUIElement = element.GetAncestor(typeof(CaptionAreaUIElement)) as CaptionAreaUIElement; if (captionAreaUIElement != null) { UltraToolTipInfo tooltipInfo = this.ultraToolTipManager1.GetUltraToolTip(grid); this.ultraToolTipManager1.AutoPopDelay = 0; tooltipInfo.ToolTipText = "This is a really long tooltip and it might be showing up behind hte form, I think."; return; } } this.ultraToolTipManager1.SetUltraToolTip(grid, null); }
Mike...you ARE the man.
Thank you so much!