Step 1 — Insert the WinForms Boilerplate

Before adding controls, your macro must include the WinFormsHelper setup. Choose the boilerplate for your scripting engine:

PowerShell

using module "[PSModuleLibrary]\WinFormsHelper.psm1"

$winformsHelper = [WinFormsHelper]::new()
$mainForm = $winformsHelper.CreateForm('Form Title')

# add control(s) statements

$winformsHelper.FinaliseDialogForm($mainForm)

if($mainForm.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK)
{
}

$winformsHelper.CleanUpForm($mainForm)

JavaScriptV8 / JScript.NET

var winformsHelper = eval(getSourceCode('WinFormsHelper', 'Macro Main Helpers\\Library', 'WinFormsHelper'));
var mainForm = winformsHelper.CreateForm('Form Title');

// add control(s) statements

winformsHelper.FinaliseDialogForm(mainForm);

if(mainForm.ShowDialog().ToString() == "OK")
{
}

winformsHelper.CleanUpForm(mainForm);
WinForms boilerplate example

Step 2 — Launch the WinForms Designer

Use the Smart Menu System to run the WinForms Designer Helper Macro. This opens the visual designer where you can drag, drop, rename, and configure controls.

WinForms Designer UI

Step 3 — Add Controls Using the Toolbox

The toolbox includes common controls such as Button, TextBox, TextArea, ListBox, ComboBox, Checkbox, Radio, and Date Picker.

The new Control dropdown lets you add any supported WinForms control:

WinForms toolbox

Step 4 — Edit Control Properties

Click any control to edit:

Press Delete to remove a control.

WinForms property panel

Step 5 — Insert the Generated AddControl Code

When you close the Designer, AdvantageBuilder generates engine-specific AddControl statements.

Example (PowerShell)

$btnSubmit = $winformsHelper.AddButton($mainForm, "Submit", 50, 50)

Example (JavaScriptV8)

var btnSubmit = winformsHelper.AddButton(mainForm, "Submit", 50, 50);

Advanced controls include a commented template showing recommended properties and engine-specific differences.

Generated WinForms code

Step 6 — Run Your Form

Run your macro. Your WinForms UI appears exactly as designed.

Final WinForms form
Continue to Getting Started