none
TooltipText in a Grid

    Question

  • Is it true that in VFP9 SP2 the tooltips associated to header and columns of a grid do no show up, even with form.showtips=.T. ?

    But the tooltip associated to the grid works, so is there a workaround using this tooltip? Normally I don't use explicit columns when designing the grid, I use a cursor as a recordsource for the grid, and set columncount = -1.


    WP
    Saturday, June 25, 2011 2:06 PM

Answers

  • Yes, it's true. One solution is to add an Access method to the grid's ToolTip to drill down and find the right tooltip. Here's the code I'm using in one application; you'll probably have to tweak it some for your needs.

     

    * Look up the tooltip for the object currently under the mouse.
    LOCAL cToolTip, aMousePos[1], oColumn, oControl
    
    cToolTip = ""
    
    IF AMOUSEOBJ(aMousePos) > 0
      oColumn = aMousePos[1]
      IF NOT ISNULL(m.oColumn) AND UPPER(oColumn.BaseClass) = "COLUMN"
        * First, grab column-level tip in case we don't find something below
        cToolTip = oColumn.ToolTipText
        
        * Now, look for the right control. Given the way we construct
        * these grids, it should be the last control.
        IF oColumn.Objects.Count > 0
          oControl = oColumn.Objects[oColumn.Objects.Count]
          IF NOT EMPTY(oControl.ToolTipText)
            cToolTip = oControl.ToolTipText
          ENDIF
        ENDIF
      ENDIF
    ENDIF
    
    return m.cToolTip

    Tamar

    Saturday, June 25, 2011 5:11 PM
    Moderator
  • It should be in Grid's ToolTip_Access method. BTW, I'm using a different method that was discussed at the UniversalThread website.
    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog

    • Marked as answer by Kee Poppy Monday, July 11, 2011 6:09 AM
    Sunday, June 26, 2011 7:53 AM
    Moderator

All replies

  • Yes, it's true. One solution is to add an Access method to the grid's ToolTip to drill down and find the right tooltip. Here's the code I'm using in one application; you'll probably have to tweak it some for your needs.

     

    * Look up the tooltip for the object currently under the mouse.
    LOCAL cToolTip, aMousePos[1], oColumn, oControl
    
    cToolTip = ""
    
    IF AMOUSEOBJ(aMousePos) > 0
      oColumn = aMousePos[1]
      IF NOT ISNULL(m.oColumn) AND UPPER(oColumn.BaseClass) = "COLUMN"
        * First, grab column-level tip in case we don't find something below
        cToolTip = oColumn.ToolTipText
        
        * Now, look for the right control. Given the way we construct
        * these grids, it should be the last control.
        IF oColumn.Objects.Count > 0
          oControl = oColumn.Objects[oColumn.Objects.Count]
          IF NOT EMPTY(oControl.ToolTipText)
            cToolTip = oControl.ToolTipText
          ENDIF
        ENDIF
      ENDIF
    ENDIF
    
    return m.cToolTip

    Tamar

    Saturday, June 25, 2011 5:11 PM
    Moderator
  • Thanks Tamar,

     

    it looks simple, but I don't know where exactly to put your sample code. Do I have to put it in some of the grid's mouse events?


    WP
    Saturday, June 25, 2011 5:28 PM
  • It should be in Grid's ToolTip_Access method. BTW, I'm using a different method that was discussed at the UniversalThread website.
    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog

    • Marked as answer by Kee Poppy Monday, July 11, 2011 6:09 AM
    Sunday, June 26, 2011 7:53 AM
    Moderator