This is my code:
- Code: Select all Expand view RUN
- #include "FiveWin.Ch"
#include "ord.ch"
#include "xbrowse.ch"
REQUEST DBFCDX
//----------------------------------------------------------------------------//
function Main()
local oWnd, oBrw, oCol
local cAlias
// customer at c:\fwh\samples
USE CUSTOMER NEW ALIAS CUSTOMER
pack
GO TOP
cAlias := Alias()
DEFINE WINDOW oWnd TITLE "Invoice"
@ 0,0 XBROWSE oBrw OF oWnd AUTOCOLS ALIAS "CUSTOMER" CELL LINES //FASTEDIT
oBrw:nMarqueeStyle := 4
oBrw:nColDividerStyle := LINESTYLE_BLACK
oBrw:lColDividerComplete := .T.
oBrw:nHeaderLines := 1.5
// Fast Edit
oBrw:nEditTypes := EDIT_GET
oBrw:lFastEdit := .t.
//Keys
oBrw:bPastEof = {|| x_AddBlank( oBrw ) } // A new line if trying to go down after the last row
oBrw:bKeyDown :={ | nKey | x_Keys(nKey, oBrw, cAlias) } //
// First col
oBrw:aCols[ 1 ]:nEditType := EDIT_GET_BUTTON
oBrw:aCols[ 1 ]:bEditBlock := {|row, col, oCol| x_InsertData() }
oBrw:bClrStd:={|| If(FIELD->MARRIED=.T.,{CLR_HRED,CLR_WHITE},{CLR_BLACK,CLR_WHITE})}
oBrw:SetRDD()
oBrw:CreateFromCode()
oWnd:oClient := oBrw
ACTIVATE WINDOW oWnd MAXIMIZED
CLOSE DATA
return (0)
//----------------------------------------------------------------------------//
//-----------------------------------------------------------------------------
FUNCTION x_Keys(nKey, oBrw, cAlias)
Do Case
Case nKey == VK_DELETE
if MsgNoYes("Want to Delete?","D E L E T E AT "+cAlias)
(cAlias)->(dbDelete())
(cAlias)->(__dbPack())
//oBrw:GoBottom()
oBrw:Refresh()
endif
//Case nKey == VK_RETURN
// msgalert("enter")
Case nKey == VK_INSERT
x_AddBlank( oBrw )
EndCase
return nil
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
FUNCTION x_AddBlank( oBrw )
DbGoBottom()
APPEND BLANK
oBrw:GoBottom()
oBrw:refresh()
oBrw:nColSel := 1
oBrw:aCols[ 1 ]:edit()
RETURN NIL
//-----------------------------------------------------------------------------
function x_InsertData()
replace field->first with "LINE "+cvaltochar(recno())
replace field->last with "RANDOM VALUE "+cvaltochar(nrandom(10))
RETURN NIL
I have some questions:
1.- Using the scroll, if trying to go down after the last row it executes bPastEof. Is it possible to limit that only to keydown´s key?.
2.- When adding a new line, I want to set the line to edit mode but I also want the button:
Uploaded with ImageShack.us
3.- When I press enter, it goes to next field. If I press enter agan, I can edit the field. Is possible with ONE enter to go to next field and edit it?.
Thanks a lot.