Windows窗体中屏蔽文本框中的中文密码?

时间:2014-08-21 07:50:02

标签: winforms passwords ime maskedtextbox chinese-locale

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

1 个答案:

答案 0 :(得分:0)

您可以使用OnKeyPress事件在TextBox中出现之前拦截输入。将输入保存在其他位置并将一些掩蔽字符放入TextBox。

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