如何使用PasswordBox的文本框?如何使用、文本框、PasswordBox

2023-09-03 04:40:52 作者:老酒续老友

我有一个 PasswordBox ,我需要使用此控件的甚至作为一个文本框。 我需要显示正常的文本,而不是典型的黑点

I have a PasswordBox and I need to use this control even as a TextBox. I need to display normal text and not the typical black dots

有一个属性来做到这一点? 谢谢你。

Is there a property to do this? Thanks.

推荐答案

下面就是你的答案:

使用一个文本框 当你想要的文字蒙面设置TextBox.UseSystemPasswordChar = TRUE; 当你想看到的文字设置TextBox.UseSystemPasswordChar = FALSE; 利润

例如:

private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
    if (checkBox1.Checked == true)
    {
        TextBox.UseSystemPasswordChar = true;
    }
    else 
    {
        TextBox.UseSystemPasswordChar = false;
    }
}

黑点,当你想要他们,也就是说,当你不知道。您可以使用什么都触发要用于打开和关闭/逻辑,但这种方式,您只使用一个控制并得到所有您指定了所需要的功能。

Black dots when you want them, words when you don't. You can use what ever trigger/logic you want for the turning on and off but this way you are only using one control and get all the functionality that you specified you needed.