- Code: Select all Expand view RUN
...
WITH OBJECT oBrw
:nEditTypes := EDIT_GET
:lFastEdit := .t.
:lF2KeyToEdit := .t.
:bPastEof := { || iif(!empty(field->codprd),dbappend(), ), oBrw:RefreshCurrent() }
WITH OBJECT :aCols[ 1 ]
:nEditType := EDIT_GET_BUTTON
:nBtnBmp := :AddBitmap( "EDIT" )
:bEditBlock := { | nRow, nCol, oCol, nKey | MsgInfo( "edit" ), nil }
:bEditWhen := { || empty(field->CODPRD) }
END
:CreateFromCode()
END
...
1) when the F2 key is pressed the cell is edited even if :bEditWhen is FALSE
2) Is it posible to trigger the :bEditBlock when F2 is pressed and only when the cell is editable ?
3) Is it possible to show the bitmap in a column ONLY when the cell is editable ?
In my sample, the field is only editable when i add a new row and field->codprd is empty.
Here is my test code
- Code: Select all Expand view RUN
#include "FiveWin.ch"
#include "xbrowse.ch"
static oWnd
//----------------------------------------------------------------------------//
function Main()
local oBrw, oCol, n
local nFor, aStru, tmpfile
REQUEST DBFCDX
rddsetdefault( "DBFCDX" )
DEFINE WINDOW oWnd FROM 1, 1 TO 20,90
aStru := {}
aadd(aStru, { "CODPRD", "C", 20, 0 })
aadd(aStru, { "NOMPRD", "C", 60,0 })
aadd(aStru, { "IMPORT", "N", 12,2 })
tmpfile := cTempFile("c:\temp",".dbf")
dbcreate(tmpfile, aStru)
USE (tmpfile) alias "TEMP" EXCL NEW
for n := 1 to 5
dbAppend()
FIELD->CODPRD := "P" + padl( n , 2,'0' )
FIELD->NOMPRD := {'ONE','TWO','THREE','FOUR','FIVE'}[ HB_RandomInt( 1, 5 ) ]
FIELD->IMPORT := HB_RandomInt( 60, 9000 )
next
dbgotop()
@ 1,0 XBROWSE oBrw OF oWnd ALIAS "TEMP" ;
COLUMNS "codprd","nomprd","import" ;
SIZES 100,300,100 ;
CELL LINES NOBORDER
WITH OBJECT oBrw
:nEditTypes := EDIT_GET
:lFastEdit := .t.
:lF2KeyToEdit := .t.
:bPastEof := { || iif(!empty(field->codprd),dbappend(), ), oBrw:RefreshCurrent() }
WITH OBJECT :aCols[ 1 ]
:nEditType := EDIT_GET_BUTTON
:nBtnBmp := :AddBitmap( "EDIT" )
:bEditBlock := { | nRow, nCol, oCol, nKey | MsgInfo( "edit" ), nil }
:bEditWhen := { || empty(field->CODPRD) }
END
:CreateFromCode()
END
oWnd:oClient := oBrw
ACTIVATE WINDOW oWnd ON INIT oBrw:setfocus()
return nil
Thanks for your attention