This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Rieko Saitoh
Posts: 58 Joined: Sat Apr 30, 2016 11:46 am
Post
by Rieko Saitoh » Thu Mar 17, 2022 4:21 pm
Hi All,
I would like to fire the event only when user manually changes the contents of the combo box from the screen. I've tried using the ComboChanged event, but the ComboChanged event also fires when the records are programmatically added to the combobox in an initialize process.
Code: Select all
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Clientwidth(484) Clientheight(300) Left(482) Top(215) Height(338) Width(499)
Define_Com Class(#PRIM_CMBX) Name(#ComboBox1) Componentversion(1) Displayposition(1) Fixedheight(False) Left(70) Parent(#COM_OWNER) Showselection(False) Showselectionhilight(False) Tabposition(1) Top(24) Comboboxstyle(DropDownList) Height(37) Width(163) Modifiedrules(IgnoreFocusChanges+IgnoreSelectionChanges)
Define_Com Class(#PRIM_CBCL) Name(#CBCL1) Displayposition(1) Parent(#ComboBox1) Source(#STD_TEXT) Usepicklist(False)
Define_Com Class(#PRIM_CBCL) Name(#CBCL2) Parent(#ComboBox1) Source(#STD_NUM) Usepicklist(False) Visible(False)
Evtroutine Handling(#com_owner.Initialize)
Set Com(#com_owner) Caption(*component_desc)
Endroutine
Evtroutine Handling(#COM_OWNER.CreateInstance)
Clr_List Named(#ComboBox1)
#STD_NUM := 1
#STD_TEXT := 'AAA'
Add_Entry To_List(#ComboBox1)
#STD_NUM := 2
#STD_TEXT := 'BBB'
Add_Entry To_List(#ComboBox1)
#STD_NUM := 3
#STD_TEXT := 'CCC'
Add_Entry To_List(#ComboBox1)
Get_Entry Number(1) From_List(#ComboBox1)
Set Com(#ComboBox1.CurrentItem) Selected(True) Focus(True)
Endroutine
Evtroutine Handling(#ComboBox1.ComboChanged)
Use Builtin(MESSAGE_BOX_SHOW) With_Args(*Default *Default *Default *Default 'ComboChanged')
Endroutine
End_Com
Should I use the traditional method of flag? Does anyone know a good way?
Thank you.
Best regards,
Rieko Saitoh
BrendanB
Posts: 134 Joined: Tue Nov 24, 2015 10:29 am
Post
by BrendanB » Thu Mar 17, 2022 5:03 pm
Hi,
one possible way (assuming you dont want to use a #prim_boln as a flag) would be to check if the #ComboBox.isRealized.isFalse and dont show the message...
Code: Select all
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) ClientWidth(484) ClientHeight(300) Left(627) Top(273) Height(337) Width(498)
Define_Com Class(#PRIM_CMBX) Name(#ComboBox1) ComponentVersion(1) DisplayPosition(1) FixedHeight(False) Left(70) Parent(#COM_OWNER) ShowSelection(False) ShowSelectionHilight(False) TabPosition(1) Top(24) ComboBoxStyle(DropDownList) Height(37) Width(163) ModifiedRules(IgnoreFocusChanges+IgnoreSelectionChanges)
Define_Com Class(#PRIM_CBCL) Name(#CBCL1) DisplayPosition(1) Parent(#ComboBox1) Source(#STD_TEXT) UsePicklist(False)
Define_Com Class(#PRIM_CBCL) Name(#CBCL2) Parent(#ComboBox1) Source(#STD_NUM) UsePicklist(False) Visible(False)
Evtroutine Handling(#com_owner.Initialize)
Set Com(#com_owner) Caption(*component_desc)
Endroutine
Evtroutine Handling(#COM_OWNER.CreateInstance)
Clr_List Named(#ComboBox1)
#STD_NUM := 1
#STD_TEXT := 'AAA'
Add_Entry To_List(#ComboBox1)
#STD_NUM := 2
#STD_TEXT := 'BBB'
Add_Entry To_List(#ComboBox1)
#STD_NUM := 3
#STD_TEXT := 'CCC'
Add_Entry To_List(#ComboBox1)
Get_Entry Number(1) From_List(#ComboBox1)
Set Com(#ComboBox1.CurrentItem) Selected(True) Focus(True)
Endroutine
Evtroutine Handling(#ComboBox1.ComboChanged)
* Dont show message if VALUE is blank or if NOT REALIZED.
If ((#ComboBox1.Value = '') *Or (#ComboBox1.IsRealized.IsFalse))
Return
Endif
Use Builtin(MESSAGE_BOX_SHOW) With_Args(*Default *Default *Default *Default ('ComboChanged ' + #ComboBox1.Value))
Endroutine
End_Com
HTH
Brendan.
Rieko Saitoh
Posts: 58 Joined: Sat Apr 30, 2016 11:46 am
Post
by Rieko Saitoh » Fri Mar 18, 2022 4:03 pm
Hi Brendan,
I will consider adding an IF statement in ComboChanged event.
Thank you for the advice!!
Best regards,
Rieko Saitoh