title: grey out a textbox until enabled by checkbox
body: <p>I'm creating a script and I want the user to mark certain checkboxes to enable txtboxes.</p>
  
  <p>When the user presses the chexbox, the textbox next to it will be enabled. If they don't, then they cannot insert text into it.</p>
  
  <p>Right now it doesn't work, has someone an idea how to change it?
  Thanks for your help!</p>
  
  <p>Here is the part of my script with the checkbox and the textbox:</p>
  
  <pre><code>#creating the whole form
   $objForm = New-Object System.Windows.Forms.Form 
   $objForm.Text = "Ofir`s script"
   $objForm.Size = New-Object System.Drawing.Size(480,240) 
   $objForm.StartPosition = "CenterScreen"
  
  
   #This creates the TextBox1
   $objTextBox1 = New-Object System.Windows.Forms.TextBox 
   $objTextBox1.Location = New-Object System.Drawing.Size(300,40) 
   $objTextBox1.Size = New-Object System.Drawing.Size(140,150)
   $objTextBox1.TabIndex = 3 
   $objTextBox1.text = Dsp.z
   $objForm.Controls.Add($objTextBox1)
  
   #This creates a checkbox for textbox1
   $objDsp2Checkbox = New-Object System.Windows.Forms.Checkbox 
   $objDsp2Checkbox.Location = New-Object System.Drawing.Size(280,40) 
   $objDsp2Checkbox.Size = New-Object System.Drawing.Size(150,20)
   $objDsp2Checkbox.TabIndex = 0
   $objForm.Controls.Add($objDsp2Checkbox)
  
  #changing the file name
  if ($objDsp2Checkbox.Checked -eq $true)
  {
  $objTextBox1.Enabled = $true  
  }
  
  elseif ($objDsp2Checkbox.Checked -eq $false)
  {
  $objTextBox1.Enabled = $false
  }    
  
  
   #makes the form appear on top of the screen
   $objForm.Topmost = $True
  
   $objForm.Add_Shown({$objForm.Activate()})
   [void] $objForm.ShowDialog()
  </code></pre>