Tabcontrol

Ask your PowerShell-related questions, including questions on cmdlet development!
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 7 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
boskap
Posts: 21
Last visit: Sun Oct 21, 2018 4:24 am

Tabcontrol

Post by boskap »

Hello

i want to start a software in background when i select the software tab
so i add this to my code

if ($tabcontrol1.SelectedTab -eq $tabpageSoftware) { Start-Process $env:windir\CCM\ClientUX\SCClient.exe -Windowstyle Hidden }

but it didnt work
the path of the software is ok

can you help me please
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Tabcontrol

Post by jvierra »

"$tabcontrol1.SelectedTab" is an "TabPage" object. It is not a string.

See: https://msdn.microsoft.com/en-us/librar ... .110).aspx
boskap
Posts: 21
Last visit: Sun Oct 21, 2018 4:24 am

Re: Tabcontrol

Post by boskap »

ok so what must i do

i write it like the sapien primal forms
https://www.sapien.com/blog/2011/10/28/ ... abcontrol/

if($tabcontrol1.SelectedTab -eq $tabpageProcess)
{
#We are on the process tab
}
else
{
#We are on another tab
}

}


sorry my english is not so good
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Tabcontrol

Post by jvierra »

if($tabcontrol1.SelectedTab.Name -eq 'tabpage1'){

You have to use the name of the tab page.
boskap
Posts: 21
Last visit: Sun Oct 21, 2018 4:24 am

Re: Tabcontrol

Post by boskap »

sorry
but it didnt work

if ($tabcontrol1.SelectedTab.Name -eq 'tabpage4') { Start-Process $env:windir\CCM\ClientUX\SCClient.exe -Windowstyle Hidden }
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Tabcontrol

Post by jvierra »

Are you sure the name is correct? Are you sure the page is selected? Have you run under the debugger and checked these items?
boskap
Posts: 21
Last visit: Sun Oct 21, 2018 4:24 am

Re: Tabcontrol

Post by boskap »

2018-08-06 23_10_40-TabPage-Sammlungs-Editor.png
2018-08-06 23_10_40-TabPage-Sammlungs-Editor.png (21.24 KiB) Viewed 2356 times
but in the debug windows i see nothing
i press the green debug play button
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Tabcontrol

Post by jvierra »

That is because you assigned "$1" which is an empty string.

The name property is as in the image "tabpage1" if you don't assign it to nothing.
boskap
Posts: 21
Last visit: Sun Oct 21, 2018 4:24 am

Re: Tabcontrol

Post by boskap »

sorry but i dont understand what you mean with $1
you say the name is tabpage1 but i only want to start the app when the software tab will be activated
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Tabcontrol

Post by jvierra »

To perform an action when a page is activated use the "click event of the page.

Code: Select all

$tabpage1_Click={
	# do something
}
This topic is 5 years and 7 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