PDA

View Full Version : فعال کردن یک ToolTip بر روی Datagrid در Vb.net



zehs_sha
یک شنبه 02 آذر 1382, 14:42 عصر
بچه من می خواهم هنگامی که موس بر روی سلول های DataGrid قرار گرفت متن ان سلول رل بر روی ToolTip نمایش بدهم

دوشنبه 03 آذر 1382, 14:21 عصر
Private hitRow As Integer
Private toolTip1 As System.Windows.Forms.ToolTip




Private Sub dataGrid1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles dataGrid1.MouseMove
Try
Dim hti As DataGrid.HitTestInfo = Me.dataGrid1.HitTest(New Point(e.X, e.Y))
Dim bmb As BindingManagerBase = Me.BindingContext(Me.dataGrid1.DataSource, Me.dataGrid1.DataMember)
If hti.Row < bmb.Count AndAlso hti.Type = DataGrid.HitTestType.Cell AndAlso hti.Row <> hitRow Then
If Not (Me.toolTip1 Is Nothing) AndAlso Me.toolTip1.Active Then
Me.toolTip1.Active = False
End If
End If
Dim tipText As String = ""
tipText = Me.dataGrid1(hti.Row, hti.Column).ToString()

If tipText <> "" Then
hitRow = hti.Row
Me.toolTip1.SetToolTip(Me.dataGrid1, tipText)
Me.toolTip1.Active = True
Else
hitRow = -1
End If
Catch
End Try
End Sub