Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid Behavior
Message
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00319786
Message ID:
00319845
Views:
20
Hi Mark.

>> Is there an easy way to control the default behavior of grid navigation when a field is entered? When I enter data into a cell, I would like the cell focus to move to the cell below, rather than to the cell to the right. Is there an easy way to do this without writing an elaborate validation method? <<

Create a custom textbox to replace the VFP standard text boxes in the grid columns. This code in Keypress:
IF nKeyCode = 13 OR nKeyCode = 9	&& Enter or Tab
  This.Move2NextRow()
  NODEFAULT
ENDIF
This code in Move2NextRow():
LOCAL lnMaxRows
WITH This.Parent.Parent
  *** Calculate the maximum number of rows in the grid
  lnMaxRows = INT( ( .Height - .HeaderHeight - IIF( INLIST( .ScrollBars, 1, 3 ), SYSMETRIC( 8 ), 0 ) ) / .RowHeight )
  *** If we are sitting on the bottom row in the visible portion of the grid,
  *** Scroll the grid down a row in case there is a next record		  
  IF .RelativeRow >= lnMaxRows
    .DoScroll( 1 )
  ENDIF   
  .ActivateCell( .RelativeRow + 1, .ActiveColumn )
ENDWITH
Marcia
Previous
Reply
Map
View

Click here to load this message in the networking platform