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.
This topic is 5 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
toddkenn@gmail.com
Posts: 28
Last visit: Sun Jan 08, 2023 7:26 am

How to add controlset to a form programatically

Post by toddkenn@gmail.com »

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. :-)
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: How to add controlset to a form programatically

Post by jvierra »

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.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: How to add controlset to a form programatically

Post by jvierra »

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.
This topic is 5 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked