Page 1 of 1

VL V15 Form: the method of firing an event only when the content of the combo box is changed manually.

Posted: Thu Mar 17, 2022 4:21 pm
by Rieko Saitoh
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

Re: VL V15 Form: the method of firing an event only when the content of the combo box is changed manually.

Posted: Thu Mar 17, 2022 5:03 pm
by BrendanB
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.

Re: VL V15 Form: the method of firing an event only when the content of the combo box is changed manually.

Posted: Fri Mar 18, 2022 4:03 pm
by Rieko Saitoh
Hi Brendan,

I will consider adding an IF statement in ComboChanged event.
Thank you for the advice!!

Best regards,
Rieko Saitoh

Re: VL V15 Form: the method of firing an event only when the content of the combo box is changed manually.

Posted: Sat Mar 19, 2022 10:41 am
by Ingmar
Isn't that what notification style is for?

It should.

https://docs.lansa.com/14/en/lansa016/p ... nstyle.htm