When an object is selected in the design, clicking on the Events icon in the toolbar of the Properties and Events pane (fourth icon from left), displays all the events available for that object (see screenshot below). These can be displayed either by category (screenshot below) or alphabetically.
For each event, you can enter the name of an existing event handler or function. Alternatively:
|you can double click on an event to create: (i) an empty function script in the Source tab of the Main Window, and (ii) an association of the newly created function with the selected event.|
|double click a button in the design tab, to directly generate the handler stub in the code window.|
The screenshot below was taken after the Click event was double-clicked. Notice that an empty event handler function called FormExample_Label1_Click has been created in the Main Window and that, in the Properties and Events pane, this function has been associated with the Click event.
Enter the required scripting code and save the project.
Writing the required scripts
After the visual design of the form is complete, form objects will typically be associated with suitable scripts. The example below is a script that adds colors when a button is clicked. The script is inserted as an event handler for the Click event of the button Button1 (the event is available in the Properties and Events pane when the button is selected in the design):
function FormExample_Button1_Click( objSender, e_EventArgs )
// Sets the ForeColor (red) of the button.
objSender.ForeColor = CLR.Static( "System.Drawing.Color" ).Red;
// Sets the BackColor (blue) of the button.
objSender.BackColor = CLR.Static( "System.Drawing.Color" ).Blue;
// Sets the form BackColor (green).
objSender.FindForm().BackColor = CLR.Static( "System.Drawing.Color" ).Green;
(C) 2018 Altova GmbH