Try OpenEdge Now
skip to main content
Introducing the Progress Developer Studio for OpenEdge Visual Designer
Creating the Customer Window : Adding event handlers
 

Adding event handlers

Adding event handlers to controls is a two-step process:
1. Subscribe to one of the events that the control supports by choosing it in the Events tab of the Properties view.
2. Code the event-handling method, using the ABL Editor.
When you choose an event in the Events tab of the Properties view, the Visual Designer generates the appropriate SUBSCRIBE statement in the source code. It also generates the event-handling method. Progress Developer Studio for OpenEdge automatically opens the class file in the ABL Editor (or switches to it if it is already open) and positions the cursor in the method definition.
Note: Most controls have a default event that you can subscribe to by double-clicking the control in the Visual Designer. The SUBSCRIBE statement is automatically added to the source code, and the cursor is positioned in the method definition.
In the Customer form you will enable the UltraGrid to save changes made to a field by running SaveRecord() after a field is edited. Also, you will enable the deletion of the contents of a field by running DeleteRecord() when the DELETE key is pressed.
To add event handlers to ultraGrid1:
1. Open customerForm.cls in the Visual Designer.
2. Select ultraGrid1 on the Visual Designer canvas, or in the drop-down list at the top of the Properties view.
3. In the Properties view, select the Events tab.
4. Scroll down to the BeforeRowUpdate event and double-click it. The Visual Designer adds a template for the event handler and positions the cursor in the method declaration in the source file.
5. Add the code in bold to the event handler declaration:
METHOD PRIVATE VOID ultraGrid1_BeforeRowUpdate(INPUT sender ASSystem.Object,
INPUT e AS Infragistics.Win.UltraWinGrid.CancelableRowEventArgs ):
THIS-OBJECT:SaveRecord().
RETURN.
END METHOD.
6. In the Properties view, scroll to the BeforeRowsDeleted event and double- click it.
7. Add the code in bold to the event handler declaration:
METHOD PRIVATE VOID ultraGrid1_BeforeRowsDeleted
(INPUT sender AS System.Object,
INPUT e AS Infragistics.Win.UltraWinGrid.BeforeRowsDeletedEventArgs ):
THIS-OBJECT:DeleteRecord().

RETURN.
END METHOD.
8. Save customerForm.cls.