Help with form - enabling/disabling a text field

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.
Locked
User avatar
dan.wilson@zgf.com
Posts: 4
Joined: Mon Jun 20, 2011 8:07 am

Help with form - enabling/disabling a text field

Post by dan.wilson@zgf.com » Mon Jun 20, 2011 8:07 am

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
dan.wilson@zgf.com
Posts: 4
Joined: Mon Jun 20, 2011 8:07 am

Help with form - enabling/disabling a text field

Post by dan.wilson@zgf.com » Mon Jun 20, 2011 9:23 am

That's it! Thanks a lot for your help-- I really appreciate it.

Locked