With XBrowse we do not write any code to Edit. We just indicate to xbrowse which columns we want to edit. XBrowse automatically handles editing, saving to database (include locking and unlocking) and refresh the current row. In case we modify a sorted column, xbrowse decides that a full refresh is required. If we are displaying totals in footers, it even automatically refresh the footers.
When we migrate to xbrowse, we need to remove all the code for formatting, editing, etc.
Please save this code into \fwh\samples folder and try:
- Code: Select all Expand view
#include "fivewin.ch"
#include "xbrowse.ch"
function main()
local oDlg, oBrw
SET DATE BRITISH
SET CENTURY ON
FWNumFormat( 'A', .t. )
USE CUSTOMER NEW ALIAS CUST SHARED
DEFINE DIALOG oDlg SIZE 700,300 PIXEL
@ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
DATASOURCE "CUST" ;
COLUMNS "First", "Age", "HireDate", "Salary", "Notes" ;
CELL LINES NOBORDER FASTEDIT
WITH OBJECT oBrw
:nEditTypes := EDIT_GET // Tell XBrowse that we want to edit all columns
:CreateFromCode()
END
ACTIVATE DIALOG oDlg CENTERED
CLOSE CUST
return nil
XBrowse automatically decides the picture for each column and displays.
For editing, just keep typing in the cell just like Excel sheet.