How can I unmask password text box and mask it bac

2019-01-07 23:17发布

How can password textbox that set to :

password_txtBox.PasswordChar ="*"

to be unmasked ( from checkbox ) and then mask again
without loosing the string inside the textbox

标签: c# textbox
7条回答
Ridiculous、
2楼-- · 2019-01-08 00:24

The VB.Net version is

Private Sub checkBoxShowPassword_CheckedChanged(sender As Object, e As System.EventArgs) Handles checkBoxShowPassword.CheckedChanged
    textBoxPassword.PasswordChar = If(checkBoxShowPassword.Checked, ControlChars.NullChar, "*"C)
End Sub

or

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
    If CheckBox1.Checked Then
        Me.txt_password.PasswordChar = "*"c
    Else
        Me.txt_password.PasswordChar = ControlChars.NullChar
    End If
End Sub
查看更多
登录 后发表回答