密码框是一种 Windows 窗体文本框,它在用户键入字符串时显示占位符。

创建密码文本框

  1. PasswordChar 属性设置为某个特定字符。

    然后,无论用户在文本框中键入什么字符,都显示为星号。

  2. 注意,您可能不想设置此属性,因为黑客可能会利用密码的最大长度来尝试猜测密码。

    InitializeMyControl程序不会自动执行;必须调用它。

即使密码未显示为纯文本,它也仍被视为纯文本字符串(除非您已实施了其他安全措施)。

     

private void InitializeMyControl()
{
   // Set to no text.
   textBox1.Text = "";
   // The password character is an asterisk.
   textBox1.PasswordChar = '*';
   // The control will allow no more than 14 characters.
   textBox1.MaxLength = 14;
}

 

 

相关文章:

  • 2021-07-25
  • 2021-08-23
  • 2021-11-01
  • 2022-12-23
  • 2021-12-26
  • 2021-10-16
  • 2021-11-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-07
  • 2021-09-06
  • 2022-03-06
相关资源
相似解决方案