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.
This topic is 6 years and 1 month 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
ALD Automotive
Posts: 11
Last visit: Thu Jun 01, 2023 4:52 am

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

Post by ALD Automotive »

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?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post by jvierra »

Not enough information. Where did you put it on the tab? What event is it in?
User avatar
ALD Automotive
Posts: 11
Last visit: Thu Jun 01, 2023 4:52 am

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

Post by ALD Automotive »

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 1970 times
ScreenShot177.jpg
ScreenShot177.jpg (30.66 KiB) Viewed 1970 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post by jvierra »

None of this explains how you are executing the code. What event are you placing the code in?
User avatar
ALD Automotive
Posts: 11
Last visit: Thu Jun 01, 2023 4:52 am

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

Post by ALD Automotive »

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.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post by jvierra »

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.
This topic is 6 years and 1 month 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