The following example shows an OCX event trigger for the NewItem event of the CSComboBox control MyCombo in control-frame CtrlFrame-2:
PROCEDURE CtrlFrame-2.MyCombo.NewItem: DEFINE INPUT-OUTPUT PARAMETER i-ComboText AS CHARACTER NO-UNDO.
DEFINE INPUT-OUTPUT PARAMETER i-KeepFocus AS INTEGER NO-UNDO.
COM-SELF:AddItem(i-ComboText, 1).
i-KeepFocus = -1.
END PROCEDURE.
This event occurs when a user enters an item in the text box that is not in the combo box list.
The programmer uses the COM-SELF handle to add the new text item to the list with the AddItem() method. Setting i-KeepFocus to -1 ensures that the control maintains input focus after the item is added to the list.
If this event procedure is in the AppBuilder-generated application file, the programmer might otherwise choose to call the AddItem() method indirectly using the component handles provided by the AppBuilder (chCtrlFrame-2) and the control-frame COM object (MyCombo property):
PROCEDURE CtrlFrame-2.MyCombo.NewItem:
DEFINE INPUT-OUTPUT PARAMETER i-ComboText AS CHARACTER NO-UNDO.
DEFINE INPUT-OUTPUT PARAMETER i-KeepFocus AS INTEGER NO-UNDO.
chCtrlFrame-2:MyCombo:AddItem(i-ComboText, 1).
i-KeepFocus = -1.
END PROCEDURE.