Creating Custom Event Handlers
When a form displays to the user, Encompass360
provides opportunities, called "events," for which you can execute
custom code. For example, an event occurs whenever the user clicks a button control or modifies the contents of a text box. By adding your own custom functionality
to these events, you can add significant functionality to your form beyond
the simple fill-in-the-blanks default behavior.
Within the Form Builder, different controls
provide different events. The button control provides a click
event while a text box control provides a change
event.
In order to add your custom code to any
event you must author an "event handler." An event handler is
the code that Encompass360 will execute at the time the associated event
occurs. For example, you can create an event handler for a button's click
event that instructs Encompass360 to copy the value of one loan field into
another.
Custom event handlers are written in either
the VB.NET
or the C# programming
language, as determined by the EventLanguage
property on the Form. You do not, however, need to be fluent in either
language to write basic event handlers.
Macros
The Form Builder provides multiple "macros"
that you can use to invoke predefined pieces of code to perform common
actions, such as copying a value from one field to another. Users who
are fluent in one or both programming languages can author far more complex
event behavior using the full power of Microsoft's .NET Framework.
Event Arguments
During the execution of certain events, such as the Format
event which is used to perform on-the-fly formatting of user input,
data you will need to control the outcome of the event is made available
to your event handler.
For example, consider the case where the Format event is being used
to force the user to input only characters in the range A through E.
With each keystroke, a Format event is triggered on the text
box control in which the user is typing. Within your event handler,
your code needs to know the text that the user has typed and, if appropriate,
needs to reformat it to remove invalid characters.
The following code snippet demonstrates what this code may look like.
Dim i as Integer
Dim NewValue
as String = ""
For i = 0 to EventArgs.Value.Length
– 1
Dim
C as String
= EventArgs.Value.Substring(i,
1)
If
C >= "A"
And C <=
"E"
then
NewValue
= NewValue
& C
End
If
Next
EventArgs.Value
= NewValue
You can create event handlers for the
following events using the Editor:
To Write Code To Trigger an Event:
Note:
To create a new custom event handler, you should first know the control
on which the event will occur.
- Select a control on
the workspace.
- On the Properties
window, click the Events button
(lighting bolt).
- Click the event name, and then click
.
- Type the code, and then click OK.
Using Macros to help create custom code.