我有一个textbox
ac# windows 窗体,我在将空值分配给PasswordChar
. 我想要做的是,如果 acheckbox
被选中,那么PasswordChar
应该是null
,即应该显示实际的文本,否则PasswordChar
应该是*
。这是我尝试过的
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (!checkBox1.Checked)
{
txtPassword.PasswordChar = '*';
}
else
{
txtPassword.PasswordChar = '';
}
}
但是这条线
txtPassword.PasswordChar = '';
正在产生错误。我什至尝试过
txtPassword.PasswordChar = null;
但我仍然得到一个错误。
请帮我更正我的代码。