0
我有下面的代碼來顯示一個文本框和複選框一個GUI:取消屏蔽密碼文本框中不能正常工作
Add-Type -Assembly 'System.Windows.Forms'
$form = New-Object Windows.Forms.Form
$password = New-Object Windows.Forms.MaskedTextBox
$password.PasswordChar = '*'
$form.Controls.Add($password)
$checkBox2 = New-Object System.Windows.Forms.CheckBox
$checkBox2.add_click($handler_button1_Click)
$form.Controls.Add($checkBox2)
$handler_button1_Click = {
if ($checkBox2.Checked) {
$password.PasswordChar = '\0' // [char]\0 tried this too
} else {
$password.PasswordChar = '*'
}
}
$form.ShowDialog()
我揭露的人物時,該複選框被選中,但我得到的異常,因爲
Cannot convert value "\0" to type "System.Char". Error: "String must be exactly one character long."
所以有人可以讓我知道我該如何處理。
謝謝'安斯加爾Wiechers' – Dotnet