Altova StyleVision 2024 Enterprise Edition

Instantiates the Form object identified by the name supplied as argument. The form must exist in the "Forms" folder of the scripting project. Returns the form object (System.Windows.Forms.Form) corresponding to the given name, or null if no form with such name exists.

 

Signature

CreateForm (strFormName : String) -> System.Windows.Forms.Form | null

 

Example

Let's assume that a form called "FormName" exists in the scripting project.

scr_cmd_createform

The following JScript code instantiates the form with some default values and displays it to the user.

 

var myForm = CreateForm( "FormName" );
if ( myForm != null )
{
  myForm.textboxFirstName.Text = "Daniela";
  myForm.textboxLastName.Text = "Heidegger";
  var dialogResult = myForm.ShowDialog();
}

 

The dialogResult can subsequently be evaluated as follows:

 

if ( dialogResult == CLR.Static( "System.Windows.Forms.DialogResult" ).OK )
   alert( "ok" );
else
   alert( "cancel" );

 

Note:The code above will work only if the DialogResult property of the "OK" and "Cancel" buttons is set correctly from the Properties pane (for example, it must be OK for the "OK" button).

© 2017-2023 Altova GmbH