Results 1 to 3 of 3

Thread: ToolTip in a Datagrid? (resolved)

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    Austin
    Posts
    397

    ToolTip in a Datagrid? (resolved)

    i used the code below to set the tooltip of an item once you click on it BUT how can you load the tooltip when the datagrid is loaded?

    VB Code:
    1. Dim dgCellDiag As TableCell = e.Item.Cells(3)
    2.         Dim dgDiag As String = dgCellDiag.Text
    3.  
    4.         Select Case e.CommandName
    5.  
    6.             Case Is = "diag"
    7.  
    8.                 e.Item.ToolTip = dgDiag
    9.  
    10.         End Select
    Last edited by texas; Feb 2nd, 2006 at 08:57 AM.

  2. #2
    Fanatic Member
    Join Date
    May 2005
    Posts
    608

    Re: ToolTip in a Datagrid?

    You can use the datagrid's ItemDataBound handler.

    The event gets fired each time a Ds row gets added to the grid.

    Example:
    VB Code:
    1. Private Sub Dg_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles Dg.ItemDataBound
    2.  
    3.  
    4. If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.Item Then
    5.  
    6.      
    7.      'do something
    8.  
    9. End if
    10.  
    11. End Sub

    That will affect all the items in the Dg, not touching the header or the footer.

    HTH
    HoraShadow

    EDIT: my vbcode tag it's not working?
    I do like the reward system. If you find that my post was useful, rate it.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    Austin
    Posts
    397

    Re: ToolTip in a Datagrid?

    this is what i did... and thank you for the idea.

    VB Code:
    1. Private Sub dgService_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgService.ItemDataBound
    2.  
    3.         Dim dgCellDiag As TableCell = e.Item.Cells(3)
    4.         Dim dgCellProc As TableCell = e.Item.Cells(5)
    5.         Dim dgDiag As String = dgCellDiag.Text
    6.         Dim dgProc As String = dgCellProc.Text
    7.  
    8.         e.Item.Cells(2).ToolTip = dgDiag
    9.         e.Item.Cells(4).ToolTip = dgProc
    10.  
    11.     End Sub

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