Adding TabControl to a GUI

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 11 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
theotherkidd
Posts: 21
Last visit: Wed May 05, 2021 2:24 pm

Adding TabControl to a GUI

Post by theotherkidd »

I have a PowerShell Studio form that I created without tabs. My question is, is there a way to add tabs via TabControl after the form has been created or do I have to start over from scatch?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Adding TabControl to a GUI

Post by jvierra »

Just add the tab control. Why would you think you can't do that? Drag and drop on the designer and arrange. You can add a tab to any form in the designer.

To add tabs just add them to the tab collection at any time.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Adding TabControl to a GUI

Post by jvierra »

To add a new tab in code:

$tabcontrol1.TabPages.Add('MyTabKey','My new tab')
User avatar
theotherkidd
Posts: 21
Last visit: Wed May 05, 2021 2:24 pm

Re: Adding TabControl to a GUI

Post by theotherkidd »

I've tried adding the tabcontrol but I lose all of my buttons, labels and textboxes. I've created multitab apps before but always did so at the start of the app. This is the first time I've tried adding tabs to a single tab app that is already in production. I don't know how to add the tabcontrol and keep all of my controls on the first tab while creating new controls on the second tab. I hope my explanation makes sense. Thanks.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Adding TabControl to a GUI

Post by jvierra »

You have to cut and paste the controls onto the new tab or the tab control will just sit on top of the existing controls.
User avatar
theotherkidd
Posts: 21
Last visit: Wed May 05, 2021 2:24 pm

Re: Adding TabControl to a GUI

Post by theotherkidd »

Got it. I'll give that a try. Thanks!
This topic is 5 years and 11 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