I am trying to show tooltips and I am using the MouseEnterElement and MouseLeaveElement events to do so. I have button in my combo in the ButtonsLeft collection. The problem I am having is that I am getting tooltips twice: once when the mouse enters the combo and once when it enters the button UIelement. Is there a way to tell when I enter the Button that I can get to the tooltip on the combo itself and remove it?
Hello,
Please let us know if you need any other assistnace.
Hi,
It's hard to tell what might be going wrong here from just a code snippet (especially since the forums destroyed the formatting). But one thing I noticed is that you seem to be applying tooltips via two different methods. In some cases you are setting the ToolTipItem on the UIElement and in others you are calling SetToolTip. You didn't include the SetToolTip method, so I'm not sure, but my guess is that it's using either a TooTip or UltraToolTipManager and not the UIElement.ToolTipItem. So that might be why you are getting two tooltips at once - since the one knows nothing about the other.
Another thing is... I'm not sure the MouseEnterElement event is a good place to set a ToolTipItem. There might be some timing issues there. I usually use a CreationFilter to apply ToolTipItem settings so that they are applied when the elements are created and not just when the mouse enters them. I could be wrong and your method might work fine, but it's a little uncertain in my mind.
If you want to apply tooltips to different parts of the grid, then I recommend that you check out the sample of this that is included with NetAdvantage.
...\2010.1\Samples\WinMisc\VB\ToolTipManager\ToolTips With Context VB
The ToolTipContextHelperForGrid.vb file is a class that you can hook up to any grid and handle certain methods to show tooltips based on the location of the mouse.
Here's my code in the MouseEnterElement event:
Public Sub grdGrid_MouseEnterElement(ByVal sender As Object, ByVal e As Infragistics.Win.UIElementEventArgs)
'this event handler sets the tooltip for a grid cell from our custom class...
Dim grdGrid As E2Grid = DirectCast(sender, E2Grid)
If TypeOf grdGrid.FindForm Is E2FormDefinition Then
Dim TheForm As E2FormDefinition = DirectCast(grdGrid.FindForm, E2FormDefinition)
Dim strToolTip As String = String.Empty
Dim blnRequired As Boolean = False
Dim strFormat As String = String.Empty
'see what type of UI element we are in...
If e.Element.GetType().Equals(GetType(Infragistics.Win.UltraWinEditors.EditorButtonUIElement)) Then
'we are in a grid editor button...
e.Element.ToolTipItem =
New EditorButtonToolTipProvider()
ElseIf e.Element.GetType().Equals(GetType(Infragistics.Win.UltraWinGrid.HeaderUIElement)) Then
'we are in a grid column header...
Dim objColumnHeaderUIElement As Infragistics.Win.UltraWinGrid.HeaderUIElement = DirectCast(e.Element, Infragistics.Win.UltraWinGrid.HeaderUIElement)
If Not objColumnHeaderUIElement Is Nothing Then
Dim aColumnHeader As Infragistics.Win.UltraWinGrid.HeaderBase = objColumnHeaderUIElement.Header
If Not aColumnHeader Is Nothing Then
If Not aColumnHeader.Column Is Nothing Then
Dim objGridColumn As clsGridColumn = Nothing
Call GetToolTipInfoForGridColumn(grdGrid, aColumnHeader.Band.Index, aColumnHeader.Column.Key, blnRequired, strToolTip, strFormat, objGridColumn)
Call SetToolTip(TheForm, grdGrid, blnRequired, strToolTip, strFormat, False, objGridColumn)
End If
ElseIf e.Element.GetType().Equals(GetType(CellUIElement)) Then
'we are in a grid cell...
Dim objCell As UltraGridCell = DirectCast(e.Element.GetContext(GetType(UltraGridCell)), UltraGridCell)
If Not objCell Is Nothing Then
If objCell.Column.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Button Then
'don't show a tooltip if the column's style is button. We will
'show the tool tip when the editor button element is entered. If
'we did show the tooltip here, we'd see two of them popup at once...
Else
Call GetToolTipInfoForGridColumn(grdGrid, objCell.Band.Index, objCell.Column.Key, blnRequired, strToolTip, strFormat, objGridColumn)
Call CheckForHyperlinkInMouseEnterElement(grdGrid, e)
End Sub
Here's my code from the MouseLeaveElement event:
Private
Sub grdGrid_MouseLeaveElement(ByVal sender As Object, ByVal e As Infragistics.Win.UIElementEventArgs)
'this event handler clears the tooltip for the passed in grid...
If Not IsNothing(e.Element.ToolTipItem) Then
Nothing
ElseIf e.Element.GetType().Equals(GetType(Infragistics.Win.UltraWinEditors.EditorButton)) Then
Call SetToolTip(TheForm, grdGrid, False, String.Empty, String.Empty, True)
ElseIf e.Element.GetType().Equals(GetType(Infragistics.Win.UltraWinGrid.CellUIElement)) Then
There's not really enough information here to go on. How are you showing the tooltips? Are you using the inbox tooltips or the UltraToolTipManager?
What is your code doing exactly?
Can you post a small sample project demonstrating the behavior you are getting so we can check it out?