none
UseSystemPasswordChar RRS feed

  • Question

  • I'm using a std textbox to enter a password.

    I would like to have the option to view the characters being typed.

    when I press the "view" button I get ...

    My code...

            private void btn_ViewPassCode_Click(object sender, EventArgs e)
            {
                switch (txt_PassCode.UseSystemPasswordChar)
                {
                    case true:
                        txt_PassCode.UseSystemPasswordChar = false;
                        break;
                    case false:
                        txt_PassCode.UseSystemPasswordChar = true;
                        break;
                }
            }

    True/False or False/True I've tried both methods. I never see the actual characters.

    Missing something

    Tac


    tac

    Friday, March 1, 2019 4:05 PM

Answers

  • Make sure that PasswordChar is not set (in Form Editor) or try this code:

       txt_PassCode.UseSystemPasswordChar = ! txt_PassCode.UseSystemPasswordChar;

       txt_PassCode.PasswordChar = (char)0;

     

    • Marked as answer by Troy22222 Friday, March 1, 2019 7:15 PM
    Friday, March 1, 2019 5:33 PM

All replies

  • Make sure that PasswordChar is not set (in Form Editor) or try this code:

       txt_PassCode.UseSystemPasswordChar = ! txt_PassCode.UseSystemPasswordChar;

       txt_PassCode.PasswordChar = (char)0;

     

    • Marked as answer by Troy22222 Friday, March 1, 2019 7:15 PM
    Friday, March 1, 2019 5:33 PM
  • Hello,

    One TextBox, textBoxPassword, one checkbox checkBoxShowPassword

    private void Form1_Shown(object sender, EventArgs e)
    {
        textBoxPassword.PasswordChar = '*';
    }

    Then

    private void checkBoxShowPassword_CheckedChanged(object sender, EventArgs e)
    {
        textBoxPassword.PasswordChar = checkBoxShowPassword.Checked ? '\0' : '*';
    }


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, March 1, 2019 6:50 PM
    Moderator
  • Thanks,

    As you mention - Just needed to delete the Default PasswordChar"*".

    Tac


    tac

    Friday, March 1, 2019 7:17 PM