Tabcontrol

Ask your Windows 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.
boskap
Posts: 21
Joined: Sun Jul 15, 2018 4:00 pm

Tabcontrol

Post by boskap » Mon Aug 06, 2018 9:23 am

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

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

Re: Tabcontrol

Post by jvierra » Mon Aug 06, 2018 9:35 am

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

See: https://msdn.microsoft.com/en-us/librar ... .110).aspx

boskap
Posts: 21
Joined: Sun Jul 15, 2018 4:00 pm

Re: Tabcontrol

Post by boskap » Mon Aug 06, 2018 9:55 am

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

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

Re: Tabcontrol

Post by jvierra » Mon Aug 06, 2018 11:47 am

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

You have to use the name of the tab page.

boskap
Posts: 21
Joined: Sun Jul 15, 2018 4:00 pm

Re: Tabcontrol

Post by boskap » Mon Aug 06, 2018 12:50 pm

sorry
but it didnt work

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

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

Re: Tabcontrol

Post by jvierra » Mon Aug 06, 2018 1:55 pm

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
Joined: Sun Jul 15, 2018 4:00 pm

Re: Tabcontrol

Post by boskap » Mon Aug 06, 2018 2:16 pm

2018-08-06 23_10_40-TabPage-Sammlungs-Editor.png
2018-08-06 23_10_40-TabPage-Sammlungs-Editor.png (21.24 KiB) Viewed 536 times
but in the debug windows i see nothing
i press the green debug play button

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

Re: Tabcontrol

Post by jvierra » Mon Aug 06, 2018 2:39 pm

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
Joined: Sun Jul 15, 2018 4:00 pm

Re: Tabcontrol

Post by boskap » Mon Aug 06, 2018 4:07 pm

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

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

Re: Tabcontrol

Post by jvierra » Mon Aug 06, 2018 4:40 pm

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

Code: Select all

$tabpage1_Click={
	# do something
}

Locked