Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Go to next row in grid
Message
From
15/04/2009 07:48:32
Reza Meamar
Homa Programming Group
Shiraz, Iran
 
 
To
15/04/2009 06:35:10
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01394916
Message ID:
01394923
Views:
67
>I have a grid in my form. I want when i press enter key in last column, first column in next row got focused.
>I can do this, but when i am in last row of grid, it dont work correctly.

>
>Here is code from a grid textbox class that moves to the same column in the next row when the user presses {TAB} or {ENTER}. You can modify it to move to the first column:
>
>
>**************************************************
>*-- Class:        txtgrdnextrow 
>*-- ParentClass:  textbox
>*-- Moves to same column in next row when tab or enter is pressed
>
>Define Class txtgrdnextrow As txtgrid
>  BorderStyle = 0
>  Height = 18
>  Margin = 0
>  SelectOnEntry = .F.
>  SpecialEffect = 1
>  Width = 100
>  Name = "xtxtgrdnextrow"
>
>  *-- Move to the same column in the next row of the grid
>  Procedure 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
>  Endproc
>
>  Procedure KeyPress
>    Lparameters nKeyCode, nShiftAltCtrl
>    If nKeyCode = 13 Or nKeyCode = 9  && Enter or Tab
>      This.move2nextrow()
>      Nodefault
>    Endif
>  Endproc
>Enddefine
>
Thanks. Let me test it.
Previous
Reply
Map
View

Click here to load this message in the networking platform