幾個關於控件的優先級: UseSystemPasswordChar > PasswordChar > 控件屬性設置,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 > 控件屬性設置