If doesn't work if i do it on new tab

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.
Locked
User avatar
ALD Automotive
Posts: 5
Joined: Wed Feb 07, 2018 10:28 pm

If doesn't work if i do it on new tab

Post by ALD Automotive » Tue Feb 13, 2018 11:23 pm

Hello,
I created simple form for creating a users at AD. it's works correctly, but if i add Tab control and put this script at second tab sript doesn't work

Code: Select all

if (($combobox1_Department.SelectedItem -eq "Sales") -or ($combobox1_Department.SelectedItem -eq "Operations") -or ($combobox1_Department.SelectedItem -eq "Accounting"))
	{
		$combobox_City.Visible =$true
		$labelГород.Visible = $true
	}
	else
	{
		$combobox_City.Visible = $false
		$labelГород.Visible = $false
	}
What's i do wrong?

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

Re: If doesn't work if i do it on new tab

Post by jvierra » Tue Feb 13, 2018 11:42 pm

Not enough information. Where did you put it on the tab? What event is it in?

User avatar
ALD Automotive
Posts: 5
Joined: Wed Feb 07, 2018 10:28 pm

Re: If doesn't work if i do it on new tab

Post by ALD Automotive » Wed Feb 14, 2018 1:15 am

Ok, i have a script (disinger in attachment). Some later i want add Tab control and at second tab write new script.
(second attachment). If i use scripts alone both works fine. But if i put second script at TAB control (page #2) it's doesn't work.
What doesn;t wokr: When i select departments (if i select accounting, operations or Sales) must be do visible new combobox $combobox_City. And it's doesn,t work.
Attachments
ScreenShot178.jpg
ScreenShot178.jpg (15.82 KiB) Viewed 277 times
ScreenShot177.jpg
ScreenShot177.jpg (30.66 KiB) Viewed 277 times

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

Re: If doesn't work if i do it on new tab

Post by jvierra » Wed Feb 14, 2018 1:36 am

None of this explains how you are executing the code. What event are you placing the code in?

User avatar
ALD Automotive
Posts: 5
Joined: Wed Feb 07, 2018 10:28 pm

Re: If doesn't work if i do it on new tab

Post by ALD Automotive » Wed Feb 14, 2018 7:15 am

I have a control combobox. Event - SelectedIndexChanged.
If i select some values in this combobox - another combobox be visible (by default it's invisible).
It's work fine at alone form. But if i add to another form control - "Tab control" and at Page2 make same control from first form (same name) and make same script code, this action (visible or invisible) doesn't work.

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

Re: If doesn't work if i do it on new tab

Post by jvierra » Wed Feb 14, 2018 5:09 pm

We cannot be of any help from simple statements about your code.

You cannot have two controls with the same name in the same container. The variable for the tab version will be different from the first one you created. Find the correct control variable and it should work.

Locked