CS-Script 3.20.0

Using WinForms

Step-by-step tutorial

The following tutorial shows how to create and execute the simple script that uses WinForm.

  1. By using any text editor (eg. Notepad.exe) create file WinForm.cs that contains the WinForm sample code.
    Click here to obtain listing of WinForm.cs

  2. Open command prompt. Make sure current directory is the directory where WinForm.cs is located.

  3. Execute the following command in command prompt:

    csws WinForm

Output

The script will create and show the following dialog.



Code discussion

In this example the script creates an instance of FCL class System.Windows.Forms.Form. The form initialisation code is placed into InitializeComponent() method to make it compatible with the Visual Studio form designer however it can be placed in any other appropriate place (eg. Form1 constructor).  

 

Hints and Tips

This example is a part of sample library (cs-script/Samples folder). It can be easily recreated to be used as a skeleton code for your WinForm script. To do this execute the following command in your code:

cscs sample WinForm

This will instruct the script engine to output sample code in a file in the current directory.

 

See Also

CS-Script tutorialsCommand-line interface