|
-
Oct 17th, 2006, 05:38 AM
#1
Thread Starter
Fanatic Member
[2005] Datagridview - Tooltip on cells ?
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
"I dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings
-
Oct 17th, 2006, 05:42 AM
#2
Re: [2005] Datagridview - Tooltip on cells ?
 Originally Posted by staticbob
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,
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
-
Oct 17th, 2006, 06:42 AM
#3
Re: [2005] Datagridview - Tooltip on cells ?
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?
Last edited by jmcilhinney; Oct 17th, 2006 at 06:46 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|