Thats it really..
多数民营真的..
I am using VS2008 Express.
我正在使用VS2008 Express。
All the samples say just to set the PasswordChar, but nothing gets masked.
所有样本都说只是为了设置PasswordChar,但没有任何东西被掩盖。
I also tried setting the "UseSystemPasswordChar" = true.. no luck..
我也试过设置“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;
The reason I'm using a TextBox is because I want the user to be able to hit return and it submits the data. Its important to note I guess that I have MultiLine = true so that I can capture the return.
我使用TextBox的原因是因为我希望用户能够点击返回并提交数据。重要的是要注意我猜我有MultiLine = true所以我可以捕获返回。
I can't seem to be able to capture a return with a maskedTextBox. All I get is a system beep.
我似乎无法使用maskedTextBox捕获返回。我得到的只是一个系统哔哔声。
a solution to either is fine for me!
对我来说任何一个解决方案都没问题!
3 个解决方案
#1
If you read the documentation is says "If the Multiline property is set to true, setting the PasswordChar property has no visual effect."
如果您阅读文档说“如果Multiline属性设置为true,则设置PasswordChar属性没有视觉效果。”
#2
UseSystemPasswordChar doesn't function when Multiline is set to true. The standard Windows Forms textbox accepts returns even when Multiline = false.
当Multiline设置为true时,UseSystemPasswordChar不起作用。即使Multiline = false,标准Windows窗体文本框也会接受返回。
Solution: Set Multiline = False, and set a button on your form to use the AcceptButton property, or capture the return/enter key in the "KeyPress" event of the textbox.
解决方案:设置Multiline = False,并在表单上设置一个按钮以使用AcceptButton属性,或捕获文本框“KeyPress”事件中的return / enter键。
#3
When using a maskedTextBox capture the key press and do something like:
当使用maskedTextBox捕获按键时,执行以下操作:
if ( e.KeyChar == 13) {
/* This is the enter key. Do stuff. */
}
#1
If you read the documentation is says "If the Multiline property is set to true, setting the PasswordChar property has no visual effect."
如果您阅读文档说“如果Multiline属性设置为true,则设置PasswordChar属性没有视觉效果。”
#2
UseSystemPasswordChar doesn't function when Multiline is set to true. The standard Windows Forms textbox accepts returns even when Multiline = false.
当Multiline设置为true时,UseSystemPasswordChar不起作用。即使Multiline = false,标准Windows窗体文本框也会接受返回。
Solution: Set Multiline = False, and set a button on your form to use the AcceptButton property, or capture the return/enter key in the "KeyPress" event of the textbox.
解决方案:设置Multiline = False,并在表单上设置一个按钮以使用AcceptButton属性,或捕获文本框“KeyPress”事件中的return / enter键。
#3
When using a maskedTextBox capture the key press and do something like:
当使用maskedTextBox捕获按键时,执行以下操作:
if ( e.KeyChar == 13) {
/* This is the enter key. Do stuff. */
}