Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DragDrop into a Grid cell.
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00112192
Message ID:
00116046
Views:
26
Edmond,

Even though the scrolled event will clear the "ActiveRow/Column" or "RelativeRow" information, you would have to calculate within the DragDrop event. Here is an example...
*/ In Drag/Drop OF THE GRID OBJECT
lparameters oSource, nXCoord, nYCoord, nState  &&default parameters
With This
  */ Determine which row the mouse is over... Then force
  */ activateRow to that row. Start count with zero
  do case
  case nYCoord <= .Top
    */ Force to scroll up a row or more, based on 
    */ distance above grid area...
    lnScroll = int( (.Top - nYCoord) / 3 )
    for ln1 = 1 to lnScroll
      .DoScroll( 0 )
    endfor

  case nYCoord >= .Top + .Height
    */ Force to scroll down a row or more, based on 
    */ distance above grid area...
    lnScroll = int( (nYCoord - .Top) / 3 )
    for ln1 = 1 to lnScroll
      .DoScroll( 1 )
    endfor
	
  otherwise
    */ Determine which row the cursor is above from
    private ln1, lnCurTop

    */ First, figure what the real row is currently over
    */ based on each container individually based on .Top Property
    lnRows   = int(( .Height - .HeaderHeight ) / .RowHeight )
    lnMinTop = .Top + .HeaderHeight
    for ln1 = 1 to lnRows
      */ When determining object, make sure to account for
      */ any top of form buffer that this container might
      */ not be at exact position 0
      lnMinX = lnMinTop + ( ln1-1 ) * .RowHeight
      lnMaxX = lnMinTop + ln1 * .RowHeight

      */ Strange artifact of dragging over with the icon
      */ cursor.  The scroll limit appears to be based on 
      */ the middle of the selected row, not the actual top
      */ or bottom of the control... Allow for test
      lnMinX = lnMinX + int( .RowHeight / 2 )
      lnMaxX = lnMaxX + int( .RowHeight / 2 )

      if between( nYCoord, lnMinX, lnMaxX )
        .activatecell( ln1, 1 )
        exit
      endif
    endfor
  endcase
EndWith
Then once you have forced the ActivateCell, the table should be force to the proper record for whatever updates you have intended. Hope this clarifies the determining factors of where to drop based on the visible viewing area of the grid.

One special note, you can do this even if the grid is on a pageframe, but you have to take other special measures to account for the pageframe's .TOP position and the tab heights before the actual page area starts for details.

Hope this helps.
Previous
Reply
Map
View

Click here to load this message in the networking platform