Form VL_SAM037: Setting Focus to a Grid Cell

LANSA

Form VL_SAM037: Setting Focus to a Grid Cell
Name: VL_SAM037

Description: The following RDMLX form demonstrates how focus can be set to a specific grid cell.

* ===================================================================
*
* Component : VL_SAM037
* Type : Form
* Ancestor : PRIM_FORM
*
* Description : Setting Focus to a Grid Cell
*
* Disclaimer : The following material is supplied as sample 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) CLIENTHEIGHT(299) CLIENTWIDTH(588) FORMPOSITION(ScreenCenter) HEIGHT(333) LEFT(298) TOP(116) WIDTH(596)
DEFINE_COM CLASS(#PRIM_GRID) NAME(#GRID_1) COLUMNBUTTONHEIGHT(18) DISPLAYPOSITION(1) HEIGHT(401) LEFT(0) PARENT(#COM_OWNER) TABPOSITION(1) TOP(0) WIDTH(342)
DEFINE_COM CLASS(#PRIM_GDCL) NAME(#GDCL_1) CAPTION('Number') CAPTIONTYPE(Caption) DISPLAYPOSITION(1) PARENT(#GRID_1) READONLY(False) SOURCE(#EMPNO) WIDTH(20)
DEFINE_COM CLASS(#PRIM_GDCL) NAME(#GDCL_2) CAPTION('Last Name') CAPTIONTYPE(Caption) DISPLAYPOSITION(2) PARENT(#GRID_1) READONLY(False) SOURCE(#SURNAME) WIDTH(40)
DEFINE_COM CLASS(#PRIM_GDCL) NAME(#GDCL_3) CAPTION('Section') CAPTIONTYPE(Caption) DISPLAYPOSITION(3) PARENT(#GRID_1) READONLY(False) SOURCE(#SECTION) WIDTH(20)
DEFINE_COM CLASS(#PRIM_GDCL) NAME(#GDCL_4) CAPTION('Salary') CAPTIONTYPE(Caption) DISPLAYPOSITION(4) PARENT(#GRID_1) READONLY(False) SOURCE(#SALARY) WIDTH(20) WIDTHTYPE(Remainder)
DEFINE_COM CLASS(#PRIM_GPBX) NAME(#GPBX_1) CAPTION('Set Focus To Grid Entry ') DISPLAYPOSITION(2) HEIGHT(177) LEFT(344) PARENT(#COM_OWNER) TABPOSITION(2) TABSTOP(False) TOP(2) WIDTH(241)
DEFINE_COM CLASS(#EMPNO.Visual) NAME(#FEMPNO) CAPTION('where the Employee Number is') DISPLAYPOSITION(1) HEIGHT(19) LABELTYPE(Caption) LEFT(20) PARENT(#GPBX_1) TABPOSITION(1) TOP(24) USEPICKLIST(False) WIDTH(193)
DEFINE_COM CLASS(#PRIM_GPBX) NAME(#GPBX_2) CAPTION('and to the Column named') DISPLAYPOSITION(2) HEIGHT(121) LEFT(11) PARENT(#GPBX_1) TABPOSITION(2) TABSTOP(False) TOP(48) WIDTH(217)
DEFINE_COM CLASS(#PRIM_RDBN) NAME(#RDBN_1) CAPTION('Number') DISPLAYPOSITION(1) LEFT(16) PARENT(#GPBX_2) TABPOSITION(1) TOP(16)
DEFINE_COM CLASS(#PRIM_RDBN) NAME(#RDBN_2) CAPTION('Last Name') DISPLAYPOSITION(2) LEFT(16) PARENT(#GPBX_2) TABPOSITION(2) TOP(40)
DEFINE_COM CLASS(#PRIM_RDBN) NAME(#RDBN_3) CAPTION('Section') DISPLAYPOSITION(3) LEFT(16) PARENT(#GPBX_2) TABPOSITION(3) TOP(64)
DEFINE_COM CLASS(#PRIM_RDBN) NAME(#RDBN_4) CAPTION('Salary') DISPLAYPOSITION(4) LEFT(16) PARENT(#GPBX_2) TABPOSITION(4) TOP(88)
DEFINE_COM CLASS(#PRIM_GPBX) NAME(#GPBX_3) CAPTION(' Where did I focus on the Grid? ') DISPLAYPOSITION(3) HEIGHT(105) LEFT(344) PARENT(#COM_OWNER) TABPOSITION(3) TABSTOP(False) TOP(184) WIDTH(241)
DEFINE_COM CLASS(#STD_ENTRY.Visual) NAME(#EntryNo) CAPTION('Row ') DISPLAYPOSITION(1) HEIGHT(19) LABELTYPE(Caption) LEFT(18) MARGINLEFT(50) PARENT(#GPBX_3) TABPOSITION(1) TOP(32) USEPICKLIST(False) WIDTH(100)
DEFINE_COM CLASS(#STD_ENTRY.Visual) NAME(#Column) CAPTION('Column') DISPLAYPOSITION(2) HEIGHT(19) LABELTYPE(Caption) LEFT(18) MARGINLEFT(50) PARENT(#GPBX_3) TABPOSITION(2) TOP(60) USEPICKLIST(False) WIDTH(100)

EVTROUTINE handling(#com_owner.Initialize)
SET #com_owner caption(*component_desc)
select (#empno #surname #section #salary) from_file(pslmst)
add_entry #grid_1
endselect
set #rdbn_1 buttonchecked(True)
ENDROUTINE

EVTROUTINE HANDLING(#FEMPNO.Changed #RDBN_1.Click #RDBN_2.Click #RDBN_3.Click #RDBN_4.Click)
selectlist #grid_1
if '#empno = #fempno'
if '#rdbn_1.buttonchecked = true'
SET #GDCL_1 FOCUS(TRUE)
endif
if '#rdbn_2.buttonchecked = true'
SET #GDCL_2 FOCUS(TRUE)
endif
if '#rdbn_3.buttonchecked = true'
SET #GDCL_3 FOCUS(TRUE)
endif
if '#rdbn_4.buttonchecked = true'
SET #GDCL_4 FOCUS(TRUE)
endif
set #grid_1.currentitem ensurevisible(true) focus(true)
invoke #grid_1.setfocus
return
endif
endselect
ENDROUTINE

EVTROUTINE Handling(#GRID_1.Changed) Options(*NOCLEARERRORS)
IF_REF Com(#GRID_1.focuscell) Is_Not(*NULL)
* The column
Change #Column #GRID_1.focuscell.Column.displayposition
* The row
Change #EntryNo #GRID_1.focuscell.item.position
ENDIF
ENDROUTINE
END_COM