Loading…

Standalone PowerShell Windows Form Designer integrated into Visual Studio Code

In the most recent release of the PowerShell Pro Tools for VSCode, I’ve added a stand-alone Windows Form Designer. This designer is built on the same code-base as the WinForm designer for Visual Studio but does not require an installation of Visual Studio to function.

Integration with VSCode

Although the designer itself is a stand-alone app, a command has been added to the PoshProTools VSCode extension to open the designer and provide the necessary file paths to generate Windows Forms. After selecting a PS1 file, you can use the PowerShell: Show Windows Forms Designer command to open the WinForm designer app.

Changes made to the design surface will result in a designer.ps1 file being generated that contains all the WinForms code.

You’ll have to do some manual work to get the form to run in this early beta version. In the form.ps1 file, make sure you have the necessary code to launch the form generated from the designer. An example of would look something like this.

[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
. "$PSScriptRoot\form.designer.ps1"
$Form1.ShowDialog()

If you want to add event handlers to your controls, just double click them in the designer and an event handler will be created in your form.ps1.

Limitations

The current implementation does not support resource files, icons or images.

Feedback

Hopefully you’ll find it useful to generate forms outside of Visual Studio. Please feel free to report any issues to our issue tracker.

Leave a Reply