April 26, 2012 / by David Corrales / PowerShell Studio 2012, PrimalForms, Software News, Windows PowerShell / 1 Comment

PowerShell Studio 2012: What’s New? (Part 3)

Last time we looked at the new Styles. Now we will take a look at the next major designer feature:

Control Sets

Control Sets are essentially custom controls that you can drag and drop from the Toolbox Panel into the designer like any other ordinary form control. They are made up of either single or multiple controls with predefined properties, events and functions.

You can access the control sets in the Toolbox Panel under the “Control Sets” tab:

Toolbox - Control Sets

PowerShell Studio 2012 comes with a number of predefined Control Sets that you can immediately use in your forms.

Sample Control Sets:

Here are some of the sample Control Sets you may find useful.


Button – Run Process

This button starts a process when pressed and displays a busy animation as long as the initiated process continues runs.


Chart – Disk Space

Insert this chart and it will automatically display the disk space usage for each physical hard drive.

Disk Space


ListView – ApplicationList

This Control Set inserts a List View that is used to determine if a specified application or file is installed. If the application is found, it will also extract the icon and display it in the ListView.

Application List


TextBox – Browse for File

This Control Set inserts a Textbox and an accompanying browse button. There is a high probability that you will need a Browse for Files at one point. This control set will handle all the backend wiring and all you will need to do is set the filter for the OpenFileDialog.

TextBox - Browse for File


Creating Custom Control Sets

The best part of Control Sets is that you can create your own. The first step of creating a Control Set is to select the controls you wish to include.

In this example, we select a Textbox and a Button that is used to display all the processes when a button is pressed.

Textbox and Button

Next select the “Create Control Set” option from either:


Create Control Set ContextMenu

Or the Ribbon:

Create Control Set Ribbon

Or use the Keyboard Short (Ctrl + T).

Next you are presented with the Create Control Set Dialog:

Create Control Set Dialog

The first tab is the “General” tab where you enter information about the control set and the icon that will be displayed in the toolbox.

The “Control Insertion” section allows you to handle the non-visual controls by either choosing to “Always Insert”the control or “Use Existing Type” action.

Use Existing Type– checks if a control of the same type exists. If the control exists in the Form, it will reference the existing control instead of inserting the new control. If the type doesn’t exist, it will insert the control. Use this action if you are using controls such as the ErrorProvider and the ToolTip controls, which don’t require multiple instances.

Always Insert– It will always insert the control regardless of whether a control of the same type already exists.

The next is the Function Tab, which allows you to check any functions you wish to include with the control set.

Functions Tab

Note: PowerShell Studio will automatically add any functions that are called from the control events.

If you select the Form as part of a control set, it will display another tab called ‘Container Tab’. In this tab you are presented with lists containing used events and properties of the form. If you check any of the events or properties, they will be applied (similar to Styles) to any form that inserts the Control Set.

Container Tab

The Fade In Form Control Set is a good example of this. It uses the Form’s Load event to trigger the timer control.

Next you press the ‘Finish’ button and Save the new Control Set:

Save the ControlSet

And now the new Control Set appears in the Toolbox pane:

Control Set in the ToolBox

Control Set Best Practices:

Here are some recommended practices when creating Control Sets:

1. Try to keep the Control Set’s size small enough so it fits in the initial form size. This may not always be the case but it helps prevents the controls from inserting outside of the form.

2. Try to keep the Anchoring of the controls to the default Top Left.

3. If you are using functions to modify form controls, then it is highly recommend to pass the form control as a parameter into the function. Functions are only inserted if they do not already exist, therefore, you have to make sure your functions can be shared over multiple instances of the Control Set. Events on the other hand are always inserted and are automatically renamed to ensure there are no conflicts.


Next: Part 4 – New Script Editor Features

RSS SAPIEN Info Center

Search the Archives

Join our mailing list

Enter your email address to subscribe to our mailing lists for Monthly Blog Digests, Product Announcements and more (you can choose which you receive once you sign-up!)





PowerShell Links