How to convert snippet for TCBrowse into XBrowse

How to convert snippet for TCBrowse into XBrowse

Postby hua » Tue Jun 28, 2016 8: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: Select all  Expand view

     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
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: How to convert snippet for TCBrowse into XBrowse

Postby nageswaragunupudi » Thu Jun 30, 2016 8: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: 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.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 80 guests