Reputation: 427
i am writing a script which reads the user details from active directory, it reads users samid and pull all his details in text boxes to display; here i am using a radio button to enable/disable all those textboes. That is radio button switches between 2 modes, readmode/writemode which enables and disables those text boxes so that they can be edited and changes can be committed.
Here is the issue, by default readmode radio button is checked and every text box is disabled, when i check the write mode button , everything gets enabled , but it stays there. when i check the readmode button again , it doesn't disable those boxes ; i tried form refresh , but it didn't work; please let me know if any alternatives.
function ReadAD( $object )
{
$TextBox2.Enabled = "False"
$TextBox3.Enabled = "False"
$TextBox4.Enabled = "False"
$TextBox5.Enabled = "False"
$TextBox6.Enabled = "False"
$TextBox7.Enabled = "False"
$TextBox8.Enabled = "False"
$TextBox9.Enabled = "False"
$RichTextBox1.Enabled = "False"
$Button4.Visible = "False"
$form1.refresh()
}
function WriteAD( $object )
{
$TextBox2.Enabled = "False"
$TextBox3.Enabled = "False"
$TextBox4.Enabled = "False"
$TextBox5.Enabled = "False"
$TextBox6.Enabled = "False"
$TextBox7.Enabled = "False"
$TextBox8.Enabled = "False"
$TextBox9.Enabled = "False"
$RichTextBox1.Enabled = "False"
$Button4.Visible = "False"
$form1.refresh()
}
Upvotes: 0
Views: 4965
Reputation: 54941
The Enabled
and Visible
properties takes a bool
, not a string
. bool
in PowerShell is $true
and $false
. Try this:
$TextBox9.Enabled = $false
$RichTextBox1.Enabled = $false
$Button4.Visible = $false
There's no need to refresh, doevents etc. At least everything works perfectly when I test it by only changing the bool
value like above.
Upvotes: 3