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 placeholder
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//all working on txtpassword textbox event
private void txtpassword_MouseClick_1(object sender, MouseEventArgs e)
{
//click on textbox clear textbox
txtpassword.Clear();
}
private void txtpassword_KeyPress(object sender, KeyPressEventArgs e)
{
//change the color of textbox text and set passwordchar property
txtpassword.ForeColor = Color.Black;
txtpassword.PasswordChar = '*';
}
private void txtpassword_Leave(object sender, EventArgs e)
{
//if txtbox not empty then no changes if txtbox value is blank then set property passwordchar and change color
if(txtpassword.Text=="")
{
txtpassword.PasswordChar = '\0';
txtpassword.ForeColor = Color.LightGray;
}
}
}
}
Comments
Post a Comment