S_227FB

LANSA

S_227FB
* ===================================================================
*
* Component : S_227FB
* Type : Form
* Ancestor : PRIM_FORM
*
* Description : Using Visual Styles for a Grid - Single Cells.
*
* Disclaimer : The following material is supplied as example material
* only. No warranty concerning this material or its use
* in any way whatsoever is expressed or implied.
*
* ===================================================================
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Height(358) Layoutmanager(#ATLM_1) Left(381) Top(181) Visualstyle(#S_227VN) Width(428)

* ===========
* Form layout
* ===========

Define_Com Class(#PRIM_GRID) Name(#GRID_1) Columnbuttonheight(20) Displayposition(1) Height(331) Left(0) Parent(#COM_OWNER) Selectionstyle(Multiple) Showbuttonselection(True) Showlines(False) Showselectionhilight(False) Showsortarrow(True) Tabposition(1) Top(0) Visualstyle(#S_227VN) Width(420)
Define_Com Class(#PRIM_GDCL) Name(#GDCL_1) Displayposition(1) Parent(#GRID_1) Sortonclick(True) Source(#GIVENAME) Width(37)
Define_Com Class(#PRIM_GDCL) Name(#GDCL_2) Displayposition(2) Parent(#GRID_1) Selectonclick(True) Sortonclick(True) Source(#SURNAME) Width(38)
Define_Com Class(#PRIM_GDCL) Name(#GDCL_3) Displayposition(3) Parent(#GRID_1) Sortonclick(True) Source(#POSTCODE) Width(24) Widthtype(Remainder)
Define_Com Class(#PRIM_ATLM) Name(#ATLM_1)
Define_Com Class(#PRIM_ATLI) Name(#ATLI_1) Attachment(Center) Manage(#GRID_1) Parent(#ATLM_1)

* ===========================
* Collection of Visual Styles
* ===========================

Define_Com Class(#PRIM_KCOL) Name(#STYLE_COLOR) Collects(#PRIM_VS) Keyedby(#STD_NUM) Style(Collection)

* =======================
* Next style/color to use
* =======================

Define Field(#NEXTSTYLE) Reffld(#STD_NUM) Default(3)

* ==========================
* Handle form initialization
* ==========================

Evtroutine Handling(#COM_OWNER.CreateInstance) Options(*NOCLEARMESSAGES *NOCLEARERRORS)
*
* Initiaze the collection of visual styles
*
Set_Ref Com(#STYLE_COLOR<1>) To(#S_227VN)
Set_Ref Com(#STYLE_COLOR<2>) To(#S_227VR)
Set_Ref Com(#STYLE_COLOR<3>) To(#S_227VG)
Set_Ref Com(#STYLE_COLOR<4>) To(#S_227VB)
*
* Populate the grid
*
Select Fields(#GRID_1) From_File(PSLMST)

* Add the employee details to the grid

Add_Entry To_List(#GRID_1)

* Make all the cells in the entry just added different colors,
* but make them the same different colors for each new row initially
* by forcing the same starting style ....

Change Field(#NEXTSTYLE) To(1)
Invoke Method(#Com_Owner.MakeRainbowCells) Inrow(#GRID_1.Currentitem.Entry)

Endselect

Endroutine

* =======================================================================
* When a grid row gets focus change it's cell colors
* =======================================================================

Evtroutine Handling(#Grid_1.ItemGotSelection) Options(*NOCLEARMESSAGES *NOCLEARERRORS)
Invoke Method(#Com_Owner.MakeRainbowCells) Inrow(#GRID_1.Currentitem.Entry)
Endroutine

* =======================================================================
* Make the colors of the cells in the current grid entry different colors
* =======================================================================

Mthroutine Name(MakeRainbowCells)
Define_Map For(*Input) Class(#Std_Num) Name(#InRow)
Define Field(#COLUMN) Reffld(#STD_NUM)

Begin_Loop Using(#COLUMN) To(3)

* Cycle through cell styles/colors 1 -> 4

Change Field(#NEXTSTYLE) To('#NextStyle + 1')
If Cond('#NextStyle > 4')
Change Field(#NEXTSTYLE) To(1)
Endif

* Set the cells visual style from the collection

Set Com(#Grid_1.Cell<#InRow #Column>) Visualstyle(#STYLE_COLOR<#NextStyle>)

End_Loop

Endroutine

End_Com