COLUMNS CLAUSE is a list of column names of the Alias assigned to the browse.
FIELDS clause is for any expressions. FIELDS clause is to be used for data from other related Aliases or any complext expressions.
When we want to display any field of the alias assigned to XBrowse, it is desirable to use COLUMNS clause but not FIELDS clause. When we use COLUMNS clause, XBrowse automatically reconginses fieldtype,fieldlen, fielddec and suitably decides, alignment, picture clauses and also automatically generates bOnPostEdit blocks and cSortOrder. We forgo this advantage if we use FIELDS clause or use OOPS syntax of creating columns by oBrw:AddCol(), etc. methods. We deirve the maximum power of XBrowse when we use the COMMAND syntax.
When both COLUMNS and FIELDS clauses are speicified, XBrowse places the columns first and then the fields. We can later rearrange the sequence of xbrowse columns.
Here is an example assuming 2 DBFs BILLS and CUSTOMER.
- Code: Select all Expand view RUN
USE BILLS
USE CUSTOMER ALIAS CUST
SET ORDER TO CUSTID
SELECT BILLS
SET RELATION TO CUSTID INTO CUST
@ 10,10 XBROWSE oBrw SIZE 400,300 PIXEL OF oDlg ;
COLUMNS 'NUMBER', 'CUSTID', 'QUANTITY', 'RATE' ;
FIELDS CUST->CUSTNAME, CUST->STATE, BILLS->QUANTITY * BILLS->RATE ;
HEADERS 'BillNo', 'ID', 'Quantity', 'Rate', 'Customer', 'State', 'Amount' ;
PICTURES nil, nil, nil, nil, nil, nil, '999,999.99' ;
ALIAS BILLS
// we defined picture clause only for the last calculated column.
// XBrowse automatically decides picture clauses for NUMBER,CUSTID,QUANITY and RATE
// based on the DbStruct() of BILLS.
oBrw:ReArrangeCols( 'BillNo', 'ID', 'Customer', 'State', 'Quantity', 'Rate', 'Amount' )
oBrw:nStretchCol := STRETCHCOL_WIDEST
bStrDataFiveWin discourages use of bStrData directly. This should be left for internal use by the XBrowse column object. Instead, it is desirable to assign the codeblock to oCol:bEditValue and specify the picture in oCol:cEditPicture. Still it is a lot more advantageous to use the COMMAND syntax rather than the OOPS style.