Custom ToolTip wouldn’t show content
Dear Experts,
I have been using a piece of sample code to show Tooltip on data grid. The last page of this link has the sample:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwinforms/html/wnf_custDatagrid.asp.
Here is my modified code. It worked in the last couple of days. Now it refuses to show any thing. I could see the correct data been loaded to the tooltip control if I uncomment those two msgboxes.
Thanks!
PublicClass MyMain
Private hitRowAsInteger
Private toolTip1As System.Windows.Forms.ToolTip
In MyMain_Load
Me.hitRow = -1
Me.toolTip1 =New ToolTip
Me.toolTip1.InitialDelay = 300
AddHandlerMe.dgbyCSR.MouseMove,AddressOf dgbyCSR_MouseMove
PrivateSub dgbyCSR_MouseMove(ByVal senderAsObject,ByVal eAs System.Windows.Forms.MouseEventArgs)Handles dgbyCSR.MouseMove
Dim gAs DataGrid =Me.dgbyCSR
Dim htiAs DataGrid.HitTestInfo = _
g.HitTest(New Point(e.X, e.Y))
Dim bmbAs BindingManagerBase = _
Me.BindingContext(g.DataSource, g.DataMember)
If hti.Row < bmb.CountAndAlso _
hti.Type = DataGrid.HitTestType.CellAndAlso _
hti.Row <> hitRowThen
IfNot (Me.toolTip1IsNothing)AndAlso _
Me.toolTip1.ActiveThen
Me.toolTip1.Active =False'turn it off
EndIf
Dim tipTextAsString = ""
If Len(Me.dgbyCSR(hti.Row, 0)) > 0Then
tipText =Me.dgbyCSR(hti.Row, 10).ToString()
'MsgBox(tipText)
If tipText <> ""Then
'new hit row
hitRow = hti.Row
Me.toolTip1.SetToolTip(Me.dgbyCSR, tipText)
' make it active so it can show
Me.toolTip1.Active =True
'MsgBox(toolTip1.ToString)
'MsgBox(tipText)
Else
hitRow = -1
EndIf
Else
hitRow = -1
EndIf
EndIf
EndSub

