简体   繁体   中英

How to put password mask in windows application c# Application

I am developing windows application to ask user to enter password in pop up box on that i am not able to put password mask,

if any on know could you please help me out this i am new to visual studio

string pin=Microsoft.VisualBasic.Interaction.InputBox("Input User Pin Number", "Pin Number", "" );

在此处输入图片说明

There is no easy way of doing this with an InputBox. (You'd have to install a hook before showing the dialog, and then when it was displayed, hunt around for its textbox control and change its styles.) Better to just say "can't". The InputBox wasn't designed to be customizable. In fact, it wasn't even designed to be used by .NET applications. It's an old classic VB thing, provided in the compatibility namespace merely to facilitate porting classic VB apps to VB.NET.

There is no real advantage in using it. Just create your own form with a label, maybe an icon, and a textbox. Set the textbox control's UseSystemPasswordChar property to true. (You could do as rashfmnb suggested and set the PasswordChar property, but it is better to use the system's password character instead of your own, that way it always matches the user's expectations.)

Be sure to display your new form with the ShowDialog method so that it will be a modal dialog (blocking call), just like InputBox.

文本框的用户PasswordChar属性

You can't mask the chars in an InputBox.

If you look at Interaction.InputBox Method on MSDN , there is no way to set it to be password input.

You will need to create a new Form, add your own Label and a TextBox, then set the PasswordChar property in the TextBox

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM