Here is my complete test that can be used like it is from inside the sample-folder
bOnPostEdit is only included because otherwise in browser 1 ( tDatabase ) values are not saved !
Code: Select all
#include 'fivewin.ch'
#include 'ord.ch'
#include 'xbrowse.ch'
REQUEST DBFCDX
FUNCTION MAIN()
LOCAL oDlg, oBrw1, oBrw2, oFont, oBtn[3], oSay[2]
LOCAL oCustomer
LOCAL nColPos := 1, nRowPos := 1
LOCAL c_path := cFilePath(GetModuleFileName( GetInstance() ) )
USE customer NEW SHARED ALIAS CUST VIA 'DBFCDX'
GO TOP
oCustomer := TDatabase():Open( , c_Path + "Customer", "DBFCDX", .T. )
oCustomer:GoTop()
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE DIALOG oDlg SIZE 800, 550 PIXEL ;
TITLE "XBrowse EDIT_GET" ;
FONT oFont
@ 5, 30 SAY oSay[1] PROMPT "Row : " + LTRIM(STR(nRowPos)) SIZE 40, 10 PIXEL COLOR 0, 12124088 FONT oFont OF oDlg
@ 5, 90 SAY oSay[2] PROMPT "Column : " + LTRIM(STR(nColPos)) SIZE 60, 10 PIXEL COLOR 0, 12124088 FONT oFont OF oDlg
@ 20,10 XBROWSE oBrw1 ;
COLUMNS "Id", 'First' , 'Last', 'Street', 'City' OF oDlg ;
SIZE -10,-160 PIXEL ;
PICTURES nil, nil, nil, nil, nil ;
COLSIZES "50, 120, 120, 110, 110" ;
DATASOURCE oCustomer ;
CELL LINES AUTOSORT NOBORDER FOOTERS
oBrw1:bClrSelFocus := { || { 0, 14540287 } }
oBrw1:bClrSel := { || { 0, 15132365 } }
oBrw1:nMarqueeStyle := 3
oBrw1:nRowHeight := 25
oBrw1:nRecSelWidth := 50
oBrw1:bRecSelHeader := { |brw| "No." } // or simply "SlNo"
oBrw1:bRecSelFooter := { |brw| brw:nLen } // or Simpy any value
oBrw1:bRecSelData := { |brw| brw:KeyNo }
oBrw1:lColChangeNotify := .T.
WITH OBJECT oBrw1:First
:nEditType = EDIT_GET // doesn't save data !!!
END
WITH OBJECT oBrw1:Last
:nEditType = EDIT_GET
:bOnPostEdit := {|o, v, n| IIF( n != VK_ESCAPE, ;
oCustomer:FieldPut( 3, v ), ), ;
oCustomer:Save(), oBrw1:RefreshCurrent() }
END
WITH OBJECT oBrw1:Street
:nEditType = EDIT_GET // doesn't save data !!!
END
WITH OBJECT oBrw1
:nStretchCol := 1
:bChange := { | nRow, nCol, nKey | nColPos := oBrw1:SelectedCol():nCreationOrder, ;
nRowPos := oBrw1:Keyno(), ;
oSay[1]:Refresh(), oBrw2:Refresh(), ;
oSay[2]:Refresh() }
:CreateFromCode()
END
// -------------------------
@ 130,10 XBROWSE oBrw2 ;
COLUMNS "Id", 'First' , 'Last', 'Street', 'City' OF oDlg ;
SIZE -10,-50 PIXEL ;
COLSIZES "50, 120, 120, 110, 110" ;
ALIAS 'CUST' ;
CELL LINES AUTOSORT NOBORDER FOOTERS
oBrw2:bClrSelFocus := { || { 0, 14540287 } }
oBrw2:bClrSel := { || { 0, 15132365 } }
oBrw2:nMarqueeStyle := 3
oBrw2:nRowHeight := 25
oBrw2:nRecSelWidth := 50
oBrw2:bRecSelHeader := { |brw| "No." }
oBrw2:bRecSelFooter := { |brw| brw:nLen }
oBrw2:bRecSelData := { |brw| brw:KeyNo }
oBrw2:lColChangeNotify := .T.
// works !!!
WITH OBJECT oBrw2:First
:nEditType = EDIT_GET
END
WITH OBJECT oBrw2:Last
:nEditType = EDIT_GET
END
WITH OBJECT oBrw2
:nStretchCol := 1
:bChange := { | nRow, nCol, nKey | nColPos := oBrw2:SelectedCol():nCreationOrder, ;
nRowPos := oBrw2:Keyno(), ;
oSay[1]:Refresh(), oBrw1:Refresh(), ;
oSay[2]:Refresh() }
:CreateFromCode()
END
@ 240, 340 BTNBMP oBtn[3] OF oDlg ;
SIZE 50, 20 PIXEL 2007 ; // B / H
PROMPT "&Exit" ;
ACTION oDlg:End() ;
FONT oFont ;
CENTER
ACTIVATE DIALOG oDlg CENTERED
CLOSE DATABASE
RELEASE FONT oFont
RETURN NIL