【问题标题】:Chinese password in masked text box in Windows Forms?Windows窗体中屏蔽文本框中的中文密码?
【发布时间】:2014-10-14 18:28:44
【问题描述】:

当 Windows 窗体 TextBox 处于密码模式时,它会受到限制并且 ImeMode 被禁用(如 herehere 所述)。如何设计一个不显示用户输入但从键盘获取/收集中文输入的文本框(基本上是在密码文本框中输入中文输入的解决方法)?

【问题讨论】:

标签: winforms passwords ime maskedtextbox chinese-locale


【解决方案1】:

您可以使用 OnKeyPress 事件在输入出现在 TextBox 之前截取输入。将输入保存在其他地方,并将一些掩码字符放入 TextBox。

private void TextBox1_KeyPress(object sender, KeyPressEventArgs e)
{
    //save the key pressed
    TextBox1.Text += "*";
    e.handled = true;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-23
    • 2011-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多