Please how can i change the asterisk of a passwordbox to char ( i will use a checkbox to show or hide the value of password) in c# when the checkbox is cheked the password box change to be like a textbox with keeping the value inside
3 Answers
To achieve this you have to mask the password character.
Please refer this.
how can i unmask c# password textbox and mask it back to password
- 1
 - 1
 
- 2,598
 - 1
 - 20
 - 42
 
Introduction
It is not clear that what you want, or what are you making in, VB or C#. But for your comfort I have written in both, as far as I understood.
Code And Example
In C#
To assign PasswordChar:
TextBox2.PasswordChar = "*";
OR
TextBox2.PasswordChar = "☻";
To remove PasswordChar:
TextBox2.PasswordChar = "";
In VB.net:
To assign PasswordChar:
TextBox2.PasswordChar = "*"
OR
TextBox2.PasswordChar = "☻"
To remove PasswordChar:
TextBox2.PasswordChar = ""
Explanation
You can assign whatever password char you want to in double quotes ahead of PasswordChar property of textbox. To remove PasswordChar there should be no value in the double quotes about which we talked above.
I hope it's clear and works perfectly!
- 900
 - 5
 - 25
 - 39
 
Use a Textbox instead and change its property yourTextBox.UseSystemPasswordChar - set it to false if you wish to see the text. If you want to use a checkbox to control that, you can use something like:
Private Sub yourCheckbox_CheckedChanged(sender As Object, e As EventArgs) Handles yourCheckbox.CheckedChanged
        If (yourCheckbox.Checked = true) then
            yourTextBox.UseSystemPasswordChar = true
        Else
            yourTextBox.UseSystemPasswordChar = false
        End If
 End Sub
This is VB.Net, but in case you are looking for C#, the corresponding code should be pretty easy to infer.
- 4,362
 - 11
 - 66
 - 106