フィールド名

SECTION(Alpha 2)

説明

フィールドをフォーム上に再利用可能パーツとして表示します。
選択肢を並べて表示したいけれども、既存のピックリストを使うのでは思った通りの動作が実現できないことがあります。例えば、データベースを検索して得た値を選択肢として表示する、といった使い方の場合、再利用可能パーツを使って実現するとよいでしょう。

再利用可能パーツのソース(SECTIONR)

Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_PANL) Defaultpty(Section) Displayposition(1) Height(68) Layoutmanager(#ATLM_1) Left(0) Tabposition(1) Top(0) Width(224) 
* Reusable consists of a combo box with a client layout item attachment 
Define_Com Class(#PRIM_CMBX) Name(#SECT_CBX) Displayposition(1) Fixedheight(False) Height(68) Left(0) Parent(#COM_OWNER) Tabposition(1) Top(0) Width(224) 
Define_Com Class(#PRIM_CBCL) Name(#CBCL_1) Displayposition(1) Parent(#SECT_CBX) Source(#SECTION) Width(20) 
Define_Com Class(#PRIM_ATLM) Name(#ATLM_1) Define_Com Class(#PRIM_ATLI) Name(#ATLI_1) Attachment(Center) Manage(#SECT_CBX) Parent(#ATLM_1)   
Define_Pty Name(Section) Get(Get_Section) Set(Set_Section)   
Evtroutine Handling(#COM_OWNER.Initialize) Options(*NOCLEARMESSAGES *NOCLEARERRORS)   
* Select all entries from PSLMST and add to our combo box 
Select Fields(#SECTION) From_File(PSLMST)   
Add_Entry To_List(#SECT_CBX)   
Endselect   
Endroutine   
Ptyroutine Name(Get_Section) 
Define_Map For(*output) Class(#SECTION) Name(#o_section)   
* Default property Get. 
*  
* Get_Entry on the combo box focus item and set the return value   
If_Ref Com(#SECT_CBX.focusitem) Is_Not(*NULL)   
Change Field(#STD_NUM) To('#SECT_CBX.FOCUSITEM.ENTRY')   
Get_Entry Number(#STD_NUM)   
Endif   
Set Com(#o_section) Value(#SECTION)   
Endroutine   
Ptyroutine Name(Set_Section) 
Define_Map For(*input) Class(#SECTION) Name(#i_section)   
* Default property Set. 
*  
* Select_List on Combo and set focus to mathing item from input   
Selectlist Named(#SECT_CBX)   
If Cond('#SECTION *ne #I_SECTION')   
Continue   
Endif   
Set Com(#SECT_CBX.currentitem) Focus(true) Selected(true)   
Endselect   
Endroutine   
End_Com

フィールドのソース

Begin_Com Role(*EXTENDS #PRIM_OBJT)
Begin_Com Role(*Visual #PRIM_EVEF) Name(#VisualEdit) Defaultvisual(True) Height(19) Usepicklist(False) Width(185)   
End_Com   
Begin_Com Role(*Visual_Part #SECTIONR) Name(#Combo) Height(19) Width(185)   
End_Com   
End_Com

フォームのソース

Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Clientheight(147) Clientwidth(492) Height(174) Left(369) Top(152)   
Define_Com Class(#SECTION.COMBO) Name(#SECT_CBX) Height(49) Left(248) Parent(#COM_OWNER) Top(8) Width(234) 
Define_Com Class(#PRIM_LTBX) Name(#LIST) Componentversion(1) Displayposition(2) Height(132) Left(6) Parent(#COM_OWNER) Showselection(True) Tabposition(2) Top(8) Width(131)
Define_Com Class(#PRIM_PHBN) Name(#PHBN_SET) Caption('Set Field Value') Displayposition(3) Left(144) Parent(#COM_OWNER) Tabposition(3) Top(24) Width(89) 
Define_Com Class(#PRIM_PHBN) Name(#PHBN_GET) Caption('Get Field Value') Displayposition(4) Left(144) Parent(#COM_OWNER) Tabposition(4) Top(80) Width(89) 
Define_Com Class(#PRIM_LBCL) Name(#LBCL_1) Displayposition(1) Parent(#LIST) Source(#SECTION) Width(20)   
Evtroutine Handling(#COM_OWNER.CreateInstance) Options(*NOCLEARMESSAGES *NOCLEARERRORS)   
Select Fields(#SECTION) From_File(PSLMST)   
Add_Entry To_List(#LIST)   
Endselect   
Endroutine   
Evtroutine Handling(#PHBN_SET.Click)   
If_Ref Com(#LIST.focusitem) Is_Not(*NULL)   
Change Field(#STD_NUM) To('#LIST.FOCUSITEM.ENTRY')   
Get_Entry Number(#STD_NUM)   
Endif   
Change Field(#SECT_CBX) To(#SECTION)   
Endroutine   
Evtroutine Handling(#PHBN_GET.Click)   
Selectlist Named(#LIST)   
If Cond('#SECTION *ne #SECT_CBX')   
Continue   
Endif   
Set Com(#LIST.currentitem) Focus(true) Selected(true)   
Endselect   
Endroutine   
End_Com

外観