XBrowse: Merge Cells Horizontally & in-cell formulas

XBrowse: Merge Cells Horizontally & in-cell formulas

Postby nageswaragunupudi » Sun Jul 12, 2020 3:14 pm

From FWH2006, it is possible to merge cells horizontally for specific rows, using
oCol:bExtend.

If specified, this codeblock is evaluated with column object as parameter. If the result is zero, the cell is painted normally. If the result is > 0, this cell width extends to that many cells on the right side.

Also if some cells in an array contain codeblocks, these are evaluated with newvalue, array, row, col as parameters and result is displayed in this cell.

Image

Sample code:
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local aData
   local oDlg, oFont, oBold, oBrw

   aData := ;
   {  { 1, "Item.11",   200, 300, { |u,a,r,c| If( u == nil, a[ r, 3 ] * a[ r, 4 ], a[ r, 4 ] := u / a[ r, 3 ] ) } } ;
   ,  { 1, "Item.12",   300, 400, { |u,a,r,c| If( u == nil, a[ r, 3 ] * a[ r, 4 ], a[ r, 4 ] := u / a[ r, 3 ] ) } } ;
   ,  { 0, "SubTotal:",   0,   0, { |u,a,r,c| FW_ArrSum( a, { |x| If( x[ 1 ] == 1, x[3]*x[4], 0 ) } ) } } ;
   ,  { 2, "Item.21",   400, 500, { |u,a,r,c| If( u == nil, a[ r, 3 ] * a[ r, 4 ], a[ r, 4 ] := u / a[ r, 3 ] ) } } ;
   ,  { 2, "Item.22",   500, 600, { |u,a,r,c| If( u == nil, a[ r, 3 ] * a[ r, 4 ], a[ r, 4 ] := u / a[ r, 3 ] ) } } ;
   ,  { 0, "SubTotal:",   0,   0, { |u,a,r,c| FW_ArrSum( a, { |x| If( x[ 1 ] == 2, x[3]*x[4], 0 ) } ) } } ;
   }

   SetGetColorFocus()

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   oBold    := oFont:Bold()

   DEFINE DIALOG oDlg SIZE 600,250 PIXEL TRUEPIXEL FONT oFont ;
      TITLE FWVERSION + " XBROWSE : COLMERGE AND INLINE FORMULAS"

   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE aData COLUMNS 2,3,4,5 ;
      HEADERS "ITEM", "QTY", "PRICE", "VALUE" ;
      PICTURES nil, "999", "999", "999,999" ;
      COLSIZES 200,100,100,100 ;
      FASTEDIT FOOTERS CELL LINES NOBORDER

   WITH OBJECT oBrw
      :nEditTypes    := EDIT_GET
      :lDisplayZeros := .f.
      :oDataFonts    := { || If( oBrw:aRow[ 1 ] == 0, oBold, oFont ) }

      WITH OBJECT :aCols[ 1 ]
         :nEditType     := EDIT_NONE
         :bExtend       := { |o| If( o:oBrw:aRow[ 1 ] == 0, 2, 0 ) }
         :bDataStrAlign := { |o| If( o:oBrw:aRow[ 1 ] == 0, AL_CENTER, AL_LEFT ) }
         :bClrStd       := { || { CLR_BLACK, If( oBrw:aRow[ 1 ] == 0, CLR_YELLOW, CLR_WHITE ) } }
         :cFooter       := "GRAND TOTAL"
      END
      WITH OBJECT :aCols[ 4 ]
         :nFooterType   := AGGR_SUM
         :bSumCondition := { |u,o| o:oBrw:aRow[ 1 ] > 0 }
      END
      :oFooterFonts  := oBold
      :bEditWhens    := { |o| o:oBrw:aRow[ 1 ] > 0 }
      :MakeTotals()

      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont, oBold

return nil
Regards

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

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 92 guests