Results 1 to 3 of 3

Thread: [2005] Datagridview - Tooltip on cells ?

  1. #1

    Thread Starter
    Fanatic Member staticbob's Avatar
    Join Date
    Jan 2005
    Location
    Manchestershire, UK Cabbage: I do
    Posts
    619

    [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

  2. #2
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: [2005] Datagridview - Tooltip on cells ?

    Quote 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:
    1. Public Class DataGridCellTips
    2. Inherits DataGrid
    3.  Private hitRow As Integer
    4.  Private hitCol As Integer
    5.  Private toolTip1 As System.Windows.Forms.ToolTip
    6.  
    7.  Public Sub New()
    8.    hitRow = -1
    9.    hitCol = -1
    10.    Me.toolTip1 = New System.Windows.Forms.ToolTip
    11.    Me.toolTip1.InitialDelay = 1000
    12.    AddHandler Me.MouseMove, AddressOf HandleMouseMove
    13.  End Sub
    14.  
    15.  Private Sub HandleMouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
    16.    Dim hti As DataGrid.HitTestInfo = Me.HitTest(New Point(e.X, e.Y))
    17.    If hti.Type = DataGrid.HitTestType.Cell AndAlso (Not (hti.Row = hitRow) OrElse Not (hti.Column = hitCol)) Then
    18.      hitRow = hti.Row
    19.      hitCol = hti.Column
    20.      If Not (Me.toolTip1 Is Nothing) AndAlso Me.toolTip1.Active Then
    21.        Me.toolTip1.Active = False
    22.      End If
    23.      Me.toolTip1.SetToolTip(Me, Me(hitRow, hitCol).ToString)
    24.      Me.toolTip1.Active = True
    25.    End If
    26.  End Sub
    27. End Class

    Hope it helps,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width