用户输入密码时,需要隐藏密码,故使用密码文本功能。
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 密码文本控件
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
textBox1.ReadOnly = true;
textBox1.UseSystemPasswordChar = true;
button1.BackColor = Color.Gray;
button1.FlatStyle = FlatStyle.Standard;
}
//输出按钮
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = "12345678";
}
}
}