Skip to content

Controls

The Controls region is used to instantiate the child control and component objects of the form. This typically includes buttons, textboxes, labels, and combo boxes. These classes are defined in the System.Windows.Forms .NET namespace, and must be instantiated after that assembly has been loaded.

This region is denoted with the #region Controls tag and must occur between the Appearance and Forms regions in a ScriptoForm script.

PowerShell
#region Controls
$FormMain = New-Object -TypeName System.Windows.Forms.Form
$GroupBoxMain = New-Object -TypeName System.Windows.Forms.GroupBox
$LabelServerName = New-Object -TypeName System.Windows.Forms.Label
$TextBoxServerName = New-Object -TypeName System.Windows.Forms.TextBox
$ButtonRun = New-Object -TypeName System.Windows.Forms.Button
$ButtonClose = New-Object -TypeName System.Windows.Forms.Button
$StatusStripMain = New-Object -TypeName System.Windows.Forms.StatusStrip
$ToolStripStatusLabelMain = New-Object -TypeName System.Windows.Forms.ToolStripStatusLabel
$ErrorProviderMain = New-Object -TypeName System.Windows.Forms.ErrorProvider
#endregion

Although called Controls, this region can contain both components and controls. A control it is more typically found in this region due to its graphical nature, and hence that is the name that is used for this regions. By convention, controls are typically defined at the top of the region (usually in the order they will appear on the Form) and components are defined at the bottom of the region.