C# - How To Set And Reset The Password Char Of A TextBox Using CheckBox

C# - How To Set And Reset The Password Char Of A TextBox Using CheckBox In C#

________________________________________________________________________

In This C# Code We Will See How To Set And Reset The Password Char Of A TextBoxe In CSharp Programming Language .

Project Source Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
namespace Project.forms
{
    public partial class Frm_Login : Form
    {
        public Frm_Login()
        {
            InitializeComponent();
        }
 
        private void checkBoxPass_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBoxPass.Checked == true)
            {

                //reset the passwordchar when CheckBox is checked and change his text

                textBoxPassWord.PasswordChar = (char)0;
                checkBoxPass.Text = "Hide Pass";
            }
            else
            {

                //set the passwordchar when CheckBox is unchecked and change his text
                textBoxPassWord.PasswordChar = '*';
                checkBoxPass.Text = "See Pass";
            }
        }
    }
}



Share this

Related Posts

Previous
Next Post »