#INCLUDE "FiveWin.ch"
#INCLUDE "XBrowse.ch"
function Main()
local oWnd, aLin := {}, i, oBar, oBrw
for i := 1 TO 6
AAdd( aLin, { i, "Description " + Str( i ), Replicate( Chr( 64 + i ), 2 ) } )
next
DEFINE WINDOW oWnd
DEFINE BUTTONBAR oBar OF oWnd 2007
DEFINE BUTTON OF oBar RESOURCE "test" ACTION MsgInfo( "Click" )
DEFINE BUTTON OF oBar RESOURCE "exit" ACTION oWnd:End()
oBrw := TxBrowse():New( oWnd )
oBrw:SetArray( aLin )
oBrw:nColDividerStyle := LINESTYLE_BLACK
oBrw:nRowDividerStyle := LINESTYLE_BLACK
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLCELL
oBrw:aCols[1]:cHeader := 'Cod'
// oBrw:aCols[1]:cEditPicture := '99'
oBrw:aCols[1]:bClrEdit := oBrw:bClrStd
oBrw:aCols[1]:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_RETURN, aLin[ oBrw:nArrayAt,1] := xVal,) }
oBrw:aCols[1]:nEditType := EDIT_GET
oBrw:aCols[1]:bEditValid := { | oGet, oCol | Valida( oGet, oCol ) }
//--
oBrw:aCols[2]:cHeader := 'Description'
oBrw:aCols[2]:bClrEdit := oBrw:bClrStd
oBrw:aCols[2]:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_RETURN, ( aLin[ oBrw:nArrayAt,2] := xVal, oBrw:GoDown(), oBrw:GoLeft() ),) }
oBrw:aCols[2]:nEditType := EDIT_GET
//--
oBrw:aCols[3]:cHeader := 'Cd'
oBrw:aCols[3]:bClrEdit := oBrw:bClrStd
oBrw:aCols[3]:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_RETURN, aLin[ oBrw:nArrayAt, 3 ] := xVal,) }
oBrw:aCols[3]:nEditType := EDIT_LISTBOX
oBrw:aCols[3]:aEditListBound := ;
oBrw:aCols[3]:aEditListTxt := { "AA", "BB", "CC", "DD", "EE", "FF", "GG", "HH" }
oBrw:CreateFromCode()
oBrw:bRClicked = { | nRow, nCol | ShowPopup( nRow, nCol, oBrw, aLin ) }
oWnd:oClient:=oBrw
ACTIVATE WINDOW oWnd
RETURN NIL
STATIC FUNCTION Valida( oGet, oCol )
local nVal := 0
if oGet:Value() > 6
MsgAlert( "Must be lower than 7" )
if MsgGet( "New value", "Enter number between 1 and 6", @nVal )
if nVal > 0 .and. nVal < 7
oGet:VarPut( nVal )
oCol:PostEdit()
return .T.
endif
endif
return .F.
endif
return .T.
function ShowPopup( nRow, nCol, oBrw, aLin )
local oMenu
MENU oMenu POPUP
MENUITEM "Add" ACTION ( AAdd( aLin, ;
{ Len( aLin ) + 1 , "New item " + Str( Len( aLin ) + 1 ), ;
Replicate( Chr( 64 + Len( aLin ) + 1 ), 2 ) } ), oBrw:Refresh() )
MENUITEM "Delete" ACTION ( ADel( aLin, oBrw:nArrayAt ), ASize( aLin, Len( aLin ) - 1 ), oBrw:Refresh() )
MENUITEM "Select 3rd Row" ACTION ( oBrw:GoTop(), oBrw:nArrayAt := 3, oBrw:nRowSel := 3, oBrw:Refresh() )
MENUITEM "Delete All" ACTION ( ASize( aLin, 0 ), oBrw:Refresh() )
MENUITEM "Report" ACTION oBrw:Report()
MENUITEM "Excel" ACTION oBrw:ToExcel()
ENDMENU
ACTIVATE POPUP oMenu WINDOW oBrw AT nRow, nCol
return nil
#include "FiveWin.ch"
#include "XBrowse.ch"
function Main()
local oWnd, oBrw, oCol
USE Customer
DEFINE WINDOW oWnd
@ 0, 0 XBROWSE oBrw OF oWnd ALIAS "Customer"
oCol = oBrw:AddCol()
oCol:bStrData = { || Customer->First }
oCol:cHeader = "First"
oCol:nEditType = EDIT_GET
oCol:bOnPostEdit = { | oCol, xVal, nKey | If( nKey == VK_RETURN, ( Customer->First := xVal, oBrw:GoRight() ),) }
oCol = oBrw:AddCol()
oCol:bStrData = { || Customer->Last }
oCol:cHeader = "Last"
oCol:nEditType = EDIT_GET
oCol:bOnPostEdit = { | oCol, xVal, nKey | If( nKey == VK_RETURN, ( Customer->Last := xVal, oBrw:GoDown(), oBrw:GoLeft() ),) }
oBrw:CreateFromCode()
oWnd:oClient = oBrw
ACTIVATE WINDOW oWnd
return nil
#include "FiveWin.ch"
#include "XBrowse.ch"
function Main()
local oWnd, oDbf, oBrw, oCol
USE Customer
DATABASE oDbf
DEFINE WINDOW oWnd
@ 0, 0 XBROWSE oBrw OF oWnd OBJECT oDbf
oBrw:CreateFromCode()
oBrw:aCols[ 1 ]:nEditType = EDIT_GET
oBrw:aCols[ 1 ]:bOnPostEdit = { | oCol, xVal, nKey | If( nKey == VK_RETURN, ( oDbf:First := xVal, oDbf:Save(), oBrw:GoRight() ),) }
oBrw:aCols[ 2 ]:nEditType = EDIT_GET
oBrw:aCols[ 2 ]:bOnPostEdit = { | oCol, xVal, nKey | If( nKey == VK_RETURN, ( oDbf:Last := xVal, oDbf:Save(), oBrw:GoDown(), oBrw:GoLeft() ),) }
oWnd:oClient = oBrw
ACTIVATE WINDOW oWnd
return nil
#include "FiveWin.ch"
#include "XBrowse.ch"
function Main()
local oWnd, oDbf, oBrw, oCol
USE Customer
DATABASE oDbf
DEFINE WINDOW oWnd
@ 0, 0 XBROWSE oBrw OF oWnd OBJECT oDbf
oCol = oBrw:AddCol()
oCol:cHeader = "First"
oCol:bStrData = { || oDbf:First }
oBrw:aCols[ 1 ]:nEditType = EDIT_GET
oBrw:aCols[ 1 ]:bOnPostEdit = { | oCol, xVal, nKey | If( nKey == VK_RETURN, ( oDbf:First := xVal, oDbf:Save(), oBrw:GoRight() ),) }
oCol = oBrw:AddCol()
oCol:cHeader = "Last"
oCol:bStrData = { || oDbf:Last }
oBrw:aCols[ 2 ]:nEditType = EDIT_GET
oBrw:aCols[ 2 ]:bOnPostEdit = { | oCol, xVal, nKey | If( nKey == VK_RETURN, ( oDbf:Last := xVal, oDbf:Save(), oBrw:GoDown(), oBrw:GoLeft() ),) }
oBrw:CreateFromCode()
oWnd:oClient = oBrw
ACTIVATE WINDOW oWnd
return nil
oBrw:aCols[ 1 ]:bOnPostEdit = { | oCol, xVal, nKey | If( nKey == VK_RETURN, ( oDbf:First := xVal, oDbf:Save(), oBrw:GoDown() ), (oDBF:First:= xVal, oDbf:Save())) }
/*
Purpose: XBrowse example with spreadsheet style editing
Note : Any alpha-numeric key triggers the edit, and up and down arrows exit the edit
Tested with FWH 8.08
*/
#include "FiveWin.ch"
#include "XBrowse.ch"
function Main()
local oWnd, oDbf, oBrw, oCol
USE Customer
DATABASE oDbf
DEFINE WINDOW oWnd
@ 0, 0 XBROWSE oBrw OF oWnd OBJECT oDbf
oBrw:lFastEdit:=.t.
oCol = oBrw:AddCol()
oCol:cHeader = "First"
oCol:bStrData = { || oDbf:First }
oBrw:aCols[ 1 ]:nEditType = EDIT_GET
oBrw:aCols[ 1 ]:bOnPostEdit = { | oCol, xVal, nKey | If( nKey == VK_RETURN, ( oDbf:First := xVal, oDbf:Save(), oBrw:GoDown() ), (oDBF:First:= xVal, oDbf:Save()) ) }
oCol = oBrw:AddCol()
oCol:cHeader = "Last"
oCol:bStrData = { || oDbf:Last }
oBrw:aCols[ 2 ]:nEditType = EDIT_GET
oBrw:aCols[ 2 ]:bOnPostEdit = { | oCol, xVal, nKey | If( nKey == VK_RETURN, ( oDbf:Last := xVal, oDbf:Save(), oBrw:GoDown() ),(oDBF:First:= xVal, oDbf:Save()) ) }
oBrw:CreateFromCode()
oWnd:oClient = oBrw
ACTIVATE WINDOW oWnd
return nil
oBrw:aCols[ 2 ]:bOnPostEdit = { | oCol, xVal, nKey | If( nKey == VK_RETURN, ( oDbf:Last := xVal, oDbf:Save(), oBrw:GoDown() ),(oDBF:First:= xVal, oDbf:Save()) ) }
David Williams wrote:James,
<<It seems that when lFastEdit is used, there is movement processing AFTER bOnPostEdit by xBrowse>>
You're right about this.
I need lFastEdit set to .t. to avoid pressing ENTER to enter each cell. However, if I want to remain in a cell when the data is wrong, I have to set lFastEdit to .f. and set it .t. when corrected. I have to do something similar when I need to move left.
Regards,
David
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 69 guests