Hi Guys,
I was wondering if its possible to get the tooltip assigned to a DataGridView Column to show on the cell as well as the column header ? It only seems to show on the column header as default.
Thanks in advance,
Bob
Printable View
Hi Guys,
I was wondering if its possible to get the tooltip assigned to a DataGridView Column to show on the cell as well as the column header ? It only seems to show on the column header as default.
Thanks in advance,
Bob
Hi Bob,Quote:
Originally Posted by staticbob
Here's an example how to create tooltips for Datagrid Cells.
You can try this;
VB Code:
Public Class DataGridCellTips Inherits DataGrid Private hitRow As Integer Private hitCol As Integer Private toolTip1 As System.Windows.Forms.ToolTip Public Sub New() hitRow = -1 hitCol = -1 Me.toolTip1 = New System.Windows.Forms.ToolTip Me.toolTip1.InitialDelay = 1000 AddHandler Me.MouseMove, AddressOf HandleMouseMove End Sub Private Sub HandleMouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Dim hti As DataGrid.HitTestInfo = Me.HitTest(New Point(e.X, e.Y)) If hti.Type = DataGrid.HitTestType.Cell AndAlso (Not (hti.Row = hitRow) OrElse Not (hti.Column = hitCol)) Then hitRow = hti.Row hitCol = hti.Column If Not (Me.toolTip1 Is Nothing) AndAlso Me.toolTip1.Active Then Me.toolTip1.Active = False End If Me.toolTip1.SetToolTip(Me, Me(hitRow, hitCol).ToString) Me.toolTip1.Active = True End If End Sub End Class
Hope it helps,
sparrow1
sparrow1, the DataGrid and the DataGridView are very different animals.
staticbob, the column's ToolTipText property is specifically for the column header. Each cell has its own ToolTipText property. As a matter of fact, the DataGridViewCell.TooTipText property help topic includes a link to an article entitled "How to: Add ToolTips to Individual Cells in a Windows Forms DataGridView Control". Sound useful? :)