Ho un textbox
in un modulo di windows C# sto riscontrando problemi nell'assegnazione di valori nulli a PasswordChar
. Quello che voglio fare è che se un checkbox
è spuntato allora il PasswordChar
dovrebbe essere null
i.e il testo attuale dovrebbe essere visualizzato altrimenti il PasswordChar
dovrebbe essere *
. Questo quello che ho provatoNull Password Char in Winform
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (!checkBox1.Checked)
{
txtPassword.PasswordChar = '*';
}
else
{
txtPassword.PasswordChar = '';
}
}
ma questa linea
txtPassword.PasswordChar = '';
si genera un errore. Ho anche provato
txtPassword.PasswordChar = null;
ma ho ancora un errore.
Si prega di aiutarmi a correggere il mio codice.
Grazie perfettamente funziona –