如何使用c#将文本显示为隐藏

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/351296/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 00:10:14  来源:igfitidea点击:

How to show a text as hidden using c#

c#

提问by Layla

I am developping in C#. I need to capture a password written inside a Text Box, but would like to not show the password that is being typed, showing instead **** or any other character to hide the password.

我正在用 C# 开发。我需要捕获写在文本框中的密码,但不想显示正在键入的密码,而是显示 **** 或任何其他字符以隐藏密码。

How can I do that? I'm sure it's by modifying an attribute, but can't find which one.

我怎样才能做到这一点?我确定它是通过修改一个属性,但找不到哪个。

采纳答案by Jimmy

http://msdn.microsoft.com/en-us/library/d3223ht2.aspx

http://msdn.microsoft.com/en-us/library/d3223ht2.aspx

set the PasswordChar property of the textbox

设置文本框的 PasswordChar 属性

回答by Patrik Svensson

There is a property on the TextBox class called "UseSystemPasswordChar" (assuming winforms) that let you do this.

TextBox 类中有一个名为“UseSystemPasswordChar”(假设为 winform)的属性,可让您执行此操作。

回答by Rob Kennedy