密码字符无法在System.Windows.Forms.TextBox上运行

Kev*_*eus 0 c# passwords textbox maskedtextbox winforms

多数民营真的..

我正在使用VS2008 Express.

所有样本都说只是为了设置PasswordChar,但没有任何东西被掩盖.

我也试过设置"UseSystemPasswordChar"= true ..没有运气..

   // 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;
Run Code Online (Sandbox Code Playgroud)

我使用TextBox的原因是因为我希望用户能够点击返回并提交数据.重要的是要注意我猜我有MultiLine = true所以我可以捕获返回.

我似乎无法使用maskedTextBox捕获返回.我得到的只是一个系统哔哔声.

对我来说任何一个解决方案都没问题!

Col*_*kay 9

如果您阅读文档说"如果Multiline属性设置为true,则设置PasswordChar属性没有视觉效果."

  • 您可能还有兴趣注意,您可以在设置为该按钮的表单上使用带有AcceptButton属性的Button来提交Enter:http://msdn.microsoft.com/en-us/library/system.windows.forms. form.acceptbutton(VS.80)的.aspx (2认同)