In version 9.12, GroupHeader logic is totally revised in XBrowse. From this version, defining group headers is extremely simple. Example:
- Code: Select all Expand view RUN
oBrw:SetGroupHeader( cHeader, nFromCol, nUptoCol, [ oFont ] )
Here is the \fwh\samples\testhead.prg
- Code: Select all Expand view RUN
// Class TXBrowse group headers demo
#include "FiveWin.ch"
#include "XBrowse.ch"
REQUEST DBFCDX
function main()
local oWnd, oBar, oFont
SET DATE ITALIAN
SET CENTURY ON
RDDSetDefault( 'DBFCDX' )
DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-12
DEFINE WINDOW oWnd MDI ;
TITLE "Testing GroupHeaders support for xBrowse"
oWnd:SetFont( oFont )
DEFINE BUTTONBAR oBar OF oWnd 2007
DEFINE BUTTON OF oBar FILE "..\bitmaps\16x16\exit.bmp" ACTION ( oWnd:End() )
DEFINE BUTTON OF oBar FILE "..\bitmaps\16x16\New.bmp" ACTION ( TestHeader() )
ACTIVATE WINDOW oWnd
RELEASE FONT oFont
return nil
function TestHeader
local oWnd, oBrw, oBold
local cAlias := cGetNewAlias( 'CUST' )
USE CUSTOMER NEW SHARED Alias ( cAlias )
DEFINE FONT oBold NAME 'VERDANA' SIZE 0,-14 BOLD
DEFINE WINDOW oWnd MDICHILD OF WndMain()
@ 0, 0 XBROWSE oBrw OF oWnd ;
COLUMNS 'First', 'Last', 'Street', 'City', 'State', ;
'Zip', 'HireDate', 'Married', 'Age' ;
/* HEADERS 'First' + CRLF + 'Name', 'Last' + CRLF + 'Name'*/ ;
COLSIZES 100,100,100,100 ;
ALIAS cAlias CELL LINES ;
FOOTERS AUTOSORT
WITH OBJECT oBrw
:SetGroupHeader( 'EMPLOYEE' + CRLF + 'NAME', 1, 2, oBold )
:SetGroupHeader( 'ADDRESS', 3, 6, oBold )
:SetGroupHeader( 'OTHER', 8, 9, oBold )
:Married:SetCheck()
:nStretchCol := :Street:nCreationOrder
END
AEval( oBrw:aCols, { |o| o:nHeadStrAlign := AL_CENTER } )
WITH OBJECT oBrw:aCols[ 6 ]
:AddBmpFile( '..\bitmaps\mail.bmp' )
:nGrpBmpNo := 1
END
oBrw:bRClicked := { || oBrw:SetGroupHeader( 'CITY', 5, 6, oBold ) }
oBrw:lAllowColReGroup := .t.
oBrw:CreateFromCode()
oWnd:oClient := oBrw
ACTIVATE WINDOW oWnd ;
ON INIT oBrw:SetFocus() ;
VALID( oBold:End(), .t. )
return nil
Result:
Supports multi-line headers, fonts and bitmaps. Even optionally supports dynamic grouping or regrouping during runtime by programmer or user.
These are the three lines defining three group headers
- Code: Select all Expand view RUN
:SetGroupHeader( 'EMPLOYEE' + CRLF + 'NAME', 1, 2, oBold )
:SetGroupHeader( 'ADDRESS', 3, 6, oBold )
:SetGroupHeader( 'OTHER', 8, 9, oBold )