Help with form - enabling/disabling a text field

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 12 years and 9 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
zgf-techpurchasing
Posts: 4
Last visit: Thu Apr 06, 2023 9:46 am

Help with form - enabling/disabling a text field

Post by zgf-techpurchasing »

Hi, I have a form where I'd like to have the initial state of a few text fields to be visible, but read-only. Then, if a checkbox is checked, I want these fields to become writeable. I see examples online using javascript, but not many with Powershell... Is there a way to do this? I've tried the following, based on one thread I found, but it didn't seem to work. All of this is in my 'generate forms' function. The textbox is read-only, but check the checkbox makes no change. Thanks for your help!

Code: Select all

#---build form objects------# checkbox $Checkbox.Font = New-Object System.Drawing.Font("Arial",12,0,3,1)
 $Checkbox.Location = New-Object System.Drawing.Point(466,44)
 $Checkbox.Size = New-Object System.Drawing.Size(134,24)
 $Checkbox.Text = "Newforma"
 $Checkbox.add_CheckedChanged($Checkbox_CheckedChanged)  # Textbox
  $PMTextbox.Font = New-Object System.Drawing.Font("Arial",8.25,0,3,1)
 $PMTextbox.Location = New-Object System.Drawing.Point(27,54)
 $PMTextbox.Size = New-Object System.Drawing.Size(355,20)
 $PMTextbox.ReadOnly = $True  #-----change state of textbox if checkbox is checked------- $NewformaCheckbox_CheckedChanged={
  If ($Form.Checkbox.checked -eq $true) {
   $Form.PMTextbox.ReadOnly = $false 
   }
User avatar
zgf-techpurchasing
Posts: 4
Last visit: Thu Apr 06, 2023 9:46 am

Help with form - enabling/disabling a text field

Post by zgf-techpurchasing »

That's it! Thanks a lot for your help-- I really appreciate it.
This topic is 12 years and 9 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