Textbox Property not changing? Checkbox event

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 10 years and 11 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
soccsupport
Posts: 17
Last visit: Mon Dec 23, 2019 11:44 am

Textbox Property not changing? Checkbox event

Post by soccsupport »

I have a simple checkbox to enable or disable a textbox ReadOnly property. So in this case if I run my Form, check the box, it enables the textbox but if I uncheck the box it will not disable the textbox. I know I missing something simple here. Don't know if this matters but this is a TabControl window.
PowerShell Code
Double-click the code block to select all.
$RemotePS_CheckedChanged={
	#TODO: Place custom script here
	If ($RemotePS.CheckState -eq 'Unchecked')
		{ $RmServer.ReadOnly="True"
		Write-Host "Should be disabled"}
	Else
		{ $RmServer.ReadOnly="False" 
		Write-Host "Should be enabled"}
Thoughts or input? Thanks.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Textbox Property not changing? Checkbox event

Post by jvierra »

It is not a text value. ReadOnly is Boolean. You need to set it to $true or $false.
User avatar
soccsupport
Posts: 17
Last visit: Mon Dec 23, 2019 11:44 am

Re: Textbox Property not changing? Checkbox event

Post by soccsupport »

Jvierra,

Thank you for the info, was spot on. Thought it was something simple, I just need to keep that logical thinking in place. :mrgreen:
This topic is 10 years and 11 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