FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to convert snippet for TCBrowse into XBrowse
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
How to convert snippet for TCBrowse into XBrowse
Posted: Tue Jun 28, 2016 08:14 AM
What's the equivalent function to allow the logic below to be applied to an xBrowse?

I only know for sure oBrw:DrawSelect() can be rewritten as oBrw:refreshCurrent().

Code (fw): Select all Collapse
     uVar := eval(oBrw:aColumns[2]:bData)
     if oBrw:lEditCol( 2, @uVar, "@!",,CLR_BLACK,CLR_WHITE )
        replace evechart->desc with uVar
        oBrw:DrawSelect()
     endif


TIA
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: How to convert snippet for TCBrowse into XBrowse
Posted: Thu Jun 30, 2016 08:13 AM
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 (fw): Select all Collapse
#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.
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion