几个关于控件的优先级: UseSystemPasswordChar > PasswordChar > 控件属性设置

 1 using System;
 2 using System.Data;
 3 using System.Drawing;
 4 using System.Text;
 5 using System.Windows.Forms;
 6 namespace Test05
 7 {
 8     public partial class Form1 : Form
 9     {
10         public Form1()
11         {
12             InitializeComponent();
13         }
14         private void Form1_Load(object sender, EventArgs e)
15         {
16             textBox1.PasswordChar = '*';
17             textBox2.UseSystemPasswordChar = true;
18         }
19     }
20 }





textBox1.PasswordChar = '*',在窗体设置中选择的是“#”,而且不报错,需要我们以代码为主,代码中设置的显示符会最终决定显示效果,而且,优先级
UseSystemPasswordChar > PasswordChar > 控件属性设置
原文地址:https://www.cnblogs.com/liuyaozhi/p/4955688.html