How to add controlset to a form programatically

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
toddkenn@gmail.com
Posts: 28
Joined: Mon Aug 29, 2016 5:46 pm

How to add controlset to a form programatically

Post by toddkenn@gmail.com » Tue Oct 09, 2018 11:38 am

Hi - I know this is probably a stupid question, but I can't seem to wrap my head around how I can click a button which will add a specific set of controls. I know you can create controlsets and then add them for reuse but I was looking to kind of leverage that feature and create something dynamic, kind of like an editor where a user can select a button that would add a specific controlset to a form. Any bump in the write direction is appriciated. :-)

User avatar
jvierra
Posts: 12895
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: How to add controlset to a form programatically

Post by jvierra » Tue Oct 09, 2018 11:42 am

Control sets cannot be dynamically assigned to a form outside of PSS. The closest you can get is to add the components of the control set to form and connect the events as needed.

Just review the generated code to see how a control set gets created and write that into your code.

User avatar
jvierra
Posts: 12895
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: How to add controlset to a form programatically

Post by jvierra » Tue Oct 09, 2018 11:45 am

You can also just add the start job button and hide it. Now just create a buton wherever you want it and have to call the "Add-JobTracker" Command to you new button. This can be added to as many buttons as you want to create.

Locked