Disable tab in tabcontrol based upon value

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 3 years and 4 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
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Disable tab in tabcontrol based upon value

Post by stevens »

Hi,

I have the code to remove a tab in a tabcontrol,
That's
$tabcontrol.TabPages.Remove($tab)

but how can I disable a tab (actually multiple only focussing on one) based upon a certain value in a grid.

Just need to code to disable it, then I can work it out :-)
Thanks.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Disable tab in tabcontrol based upon value

Post by jvierra »

Only one tab can be enabled at a time and that is the one that is visible. Just make the tab you want the visible tab.

If you are asking how to prevent a user from changing tabs then just catch the tab changing even and throw it away. This is the easiest way to control navigation.
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: Disable tab in tabcontrol based upon value

Post by stevens »

Thanks!
This topic is 3 years and 4 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