Page 1 of 1

Help with form - enabling/disabling a text field

Posted: Mon Jun 20, 2011 8:07 am
by dan.wilson@zgf.com
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 
   }

Help with form - enabling/disabling a text field

Posted: Mon Jun 20, 2011 9:23 am
by dan.wilson@zgf.com
That's it! Thanks a lot for your help-- I really appreciate it.