Is there a way to pull data from a cell in a grid without activating the recordsource's record?

已答覆 Is there a way to pull data from a cell in a grid without activating the recordsource's record?

  • 2012年3月8日 6:46
     
     

    Through info I've found here and other places, I've developed a way to pop a tool tip for a cell in a grid.  Unfortunately it has a side effect that I would like to get rid.  In it's current state, in order for the tool tip to work, the current record has to be moved to the record related to the cell on which the mouse is hovering.

    I would really like to get away from this behavior and thus am asking if there is a way to pull the data from a cell that the mouse is hovering over without moving the record pointer of the grid's recordsource related to said cell?

    Any thoughts, ideas, pointers would be greatly appreciated.

    Rob.

     


全部回复

  • 2012年3月8日 7:44
    答复者
     
     

    Hi Rob,

    I avoided this problem by removing the regular textboxes within the columns and placing containers instead (see hardcopy below). That way the rows have a height of e.g. 100 px or more and I can arrange my fields in multiple lines and have no need for horizontal scrollbars, as all needed info is always completely on display. AND I don't need column/row specific tooltips.

    JM2C ;-)


    Gruss / Best regards -Tom 010101100100011001010000011110000101001001101111011000110110101101110011

  • 2012年3月8日 8:51
     
     

    The nature of the grid is not as it looks, it only has one (current) control for each column and they are not repeatedly instanciated, they are only repeatedly drawn. Therefor you can't read from rows not active.

    Toms solution to display such texts in the first place is a solution adapting to that situation, of course..

    Even without the grid, you can only adress one row of an alias at any time, anyway. But you might try to put tooltips into a seperate alias and navigate in that alias, leaving the actverow of the grid recordsource, where it is. You only need to determine where in the secondary alias to navigate, somehow, eg by gridhittest and grid.activerow and grid.relativerow, but this all depends on the grid having focus.

    Using an array of controls would be simpler for just that case, but needs much more code for scrolling, also a listbox and itemtips would help to provide the tooltips as tooltips, but listbox of course limits what you can display, as each listbox column is not having a control.

    If all else fails you could go for the webbrowser control ad display a html table with tooltips instead.

    Bye, Olaf.

  • 2012年3月9日 4:45
     
     

    So what you are telling me is that there really isn't a way to do what I asked... Well then, we shouldn't mark something that isn't an answer as an answer... :-)

    Rob

  • 2012年3月9日 22:00
    答复者
     
     已答复 包含代码

    Try putting this code in the grid's ToolTipText_Access method:


    LOCAL cTip   * Let components have their own tooltips. * Look up the tooltip for the object currently under the mouse. LOCAL aMousePos[1], oColumn, oControl cTip = ""

    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.           oControl = EVALUATE("oColumn." + oColumn.CurrentControl)           IF NOT EMPTY(oControl.ToolTipText)              cTip = oControl.ToolTipText          ENDIF       ENDIF ENDIF ENDIF RETURN m.cTip



  • 2012年3月10日 7:27
     
     

    Well, it was a good alternative, wasn't it? It's my taste, what I propose as an answer and it's your choice, what you take, no need to comment that way.

    I also proposed another solution you didn't gave feedback on...

    Bye, Olaf.

  • 2012年3月13日 3:18
    版主
     
      包含代码

    Adding tooltips in grid is not a simple problem and I remember some ingenious solutions in Russian forum. Here is the code that I think works for me:

    Grid class MouseLeave:

    lparameters nButton, nShift, nXCoord, nYCoord
    local lcCur, llST, llShowTips
    llShowTips = .F.
    this.tooltiptext= ""
    lcCur=set("CURSOR")
    set cursor off
    IF type('thisform.ShowTips') <> 'U'
      llST = thisform.ShowTips
      thisform.showtips = .f.  && now turn off currently displayed tip
      llShowTips = .T.
    ENDIF 
    *=Sleep(100)
    INKEY(.1)
    IF m.llShowTips
      thisform.ShowTips = m.llST
    ENDIF
      
    set cursor &lcCur

    Grid class MouseEnter:

    LPARAMETERS nButton, nShift, nXCoord, nYCoord
    LOCAL ARRAY aCurEvent[1]
    
    aevents[aCurEvent,0]
    loCalledBy = aCurEvent[1] && should be a Header object
    
    if vartype(m.loCalledBy)= "O" and upper(m.loCalledBy.baseclass) = 'HEADER'
      IF NOT EMPTY(m.loCalledBy.ToolTipText)
         this.ToolTipText = m.loCalledBy.ToolTipText
      endif   
    endif

    Also there is another method:

    * Method BindMouseEvents
    
    local loColumn, loControl
    * Delegate header's MouseEnter and MouseLeave to grid's MouseEnter/MouseLeave
    * DECLARE Sleep IN kernel32 integer
    
    for each loColumn in this.columns
    
       for each loControl in m.loColumn.controls
          if upper(m.loControl.baseclass) = "HEADER"
             bindevent(m.loControl,"MouseEnter",this,"MouseEnter")
             bindevent(m.loControl,"MouseLeave",this,"MouseLeave")
          else
             *!*	                    if upper(m.loControl.baseclass) = "TEXTBOX"
             *!*	                        bindevent(m.loControl,"DblClick",this,"DblClick")
             *!*	                        bindevent(m.loControl,"KeyPress",this,"KeyPress")
             *!*	                    endif
          endif
       endfor
    endfor

    which is called from the header.

    Although now, when I read that code, I see I used all this code to fix newly introduced bug in VFP SP2 for missing tooltips for the Headers. So, it's slightly different issue.

    In UniversalThread website there were several threads on the topic of displaying tooltip for the grid's controls. Let me know if you want the messages.


    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog

  • 2012年3月14日 17:49
     
      包含代码

    Try putting this code in the grid's ToolTipText_Access method:


    LOCAL cTip   * Let components have their own tooltips. * Look up the tooltip for the object currently under the mouse. LOCAL aMousePos[1], oColumn, oControl cTip = ""

    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.           oControl = EVALUATE("oColumn." + oColumn.CurrentControl)           IF NOT EMPTY(oControl.ToolTipText)              cTip = oControl.ToolTipText          ENDIF       ENDIF ENDIF ENDIF RETURN m.cTip



    Tamar;

    Where / how are you setting the tooltiptext for the currentControl?  Is there a way to edit toolTipText_Access in a visual class?

    Thanks,
    Rob.


    • 已编辑 Dwntrdr 2012年3月14日 17:50 added question
    • 已标记为答案 Dwntrdr 2012年3月21日 16:56
    • 取消答案标记 Dwntrdr 2012年3月21日 16:56
    •  
  • 2012年3月14日 20:37
    答复者
     
     

    If you just have a grid where ColumnCount is set to a positive number, you can edit ToolTipText for the columns or controls inside them normally (that is, in the Property Sheet).

    If you're using ColumnCount = -1, you'll have to make sure that you're using a custom Column class by setting ColumnClass and ColumnClassLib for the grid. In that case, you'll probably want to use the Column class's ToolTipText_Access method to figure out what the tooltip should be.

    Tamar

  • 2012年3月21日 16:58
     
     

    Still haven't had a chance to fully implement this, but preliminary research suggests that a combination of ideas here will help me accomplish what I hope to.

    Thanks!
    Rob.