Form - CloseForm Method

CloseForm closes the form

Member of Form (PRIM_FORM)


The CloseForm closes the form causing the Closing event to fire.
When you use the CloseForm method, the form is no longer visible, but the logic, variables, components and values remain active.
When you show a form that has previously been closed using the CloseForm method, the CreateInstance and Initialize events will not be fired.
The CloseForm and HideForm methods are very similar, but CloseForm is more efficient for internal resource utilization.
Explicitly using the CloseForm method will result in the CloseQuery event being ignored. To ensure this is called, use the CloseFormQuery method.


This example demonstrate the behaviour of CloseForm and CloseFormQuery.
Function Options(*Direct)
Begin_Com Role(*EXTENDS #PRIM_form) Caption('CloseQuery') Height(211) Width(496) Clientwidth(480) Clientheight(172) Left(154) Top(210)
   Define_Com Class(#PRIM_CKBX) Name(#CanClose) Caption('Check to let the form close when queried') Displayposition(1) Left(15) Marginleft(2) Parent(#COM_OWNER) Tabposition(1) Top(6) Width(266)
   Define_Com Class(#PRIM_PHBN) Name(#CloseForm) Caption('CloseForm') Displayposition(2) Left(16) Parent(#COM_OWNER) Tabposition(2) Top(32) Width(161)
   Define_Com Class(#PRIM_PHBN) Name(#CloseFormQuery) Caption('CloseFormQuery') Displayposition(3) Left(16) Parent(#COM_OWNER) Tabposition(3) Top(64) Width(161)
   Evtroutine Handling(#Com_owner.CloseQuery) Continue(#Continue)
      #Continue := (#CanClose.ButtonState = Checked)
   Evtroutine Handling(#CloseForm.Click)
   Evtroutine Handling(#CloseFormQuery.Click)

See also

All Component Classes

Technical Reference

LANSA Version 15, April 2020