See what’s changed lately by reading the project history.
It’s common knowledge that the UseSystemPasswordChar and PasswordChar properties of the System.Windows.Forms.TextBox control let you obscure user input of secret information such as passwords. But you may have wanted behavior such as touch-screen devices exhibit: user input is momentarily displayed before being replaced by a password character. TextBox can’t do that.
PasswordTextBox is what you were looking for.
- Accept user input via the keyboard, the clipboard, and drag-and-drop
- Prevent the user or system from copying control content to the clipboard if a password character is in effect
- Show input just once before replacing it with the password character, never allowing any input to be revealed again after it has been obscured
- Support the use of the system-defined password character
- Support the use of a custom password character
- Support the use of no password character at all (which makes the control behave like a standard text box)
- Support variable delay in connection with the password character
- Observe system settings governing text quality (i.e., antialiasing)
- Support user input via the keyboard by momentarily displaying each typed character
- Support user input via the clipboard by momentarily displaying pasted content
- Support user input via drag-and-drop by momentarily displaying dropped content
Install the NuGet package. You can do this using the Visual
Studio NuGet plugin, or from the command line in your project folder:
nuget install PasswordTextBox-Control
.
Using the Visual Studio Windows Forms Designer is optional, and configuring it requires some manual steps. Once PasswordTextBoxControl.dll is a reference of your project, you need to add the control to the Visual Studio Toolbox so it can be dropped on forms in the designer:
- Click Choose Toolbox Items… in the Tools menu.
- On the .NET Framework Components tab of the Choose Toolbox Items dialog box, click the Browse… button.
- Navigate to the packages folder of your project, and within that find the PasswordTextBoxControl.dll version that corresponds to the .NET Framework version you’re using.
- Click OK to save the changes to the toolbox.
- Look for PasswordTextBox among Common Controls in the toolbox.
See the PasswordTextBox.Test.Gui project in this solution for a demonstration of the behavior of the control. Salient properties include:
If true
, this property makes user input appear as bullet characters after it
momentarily appears normally. If false
, then
PasswordChar takes effect.
This property defaults to true
.
This property makes user input appear as a specific character after it
momentarily appears normally. The value of this property has no effect unless
UseSystemPasswordChar is false
.
This property defaults to '\0'
(the null character), which makes the control
behave like a standard text box if
UseSystemPasswordChar is false
.
This property controls the time in milliseconds during which user input appears normally before appearing as the password character.
This property defaults to 1000 (i.e., one second).
As you might expect, this property stores user input regardless of any password character that may be in effect.
To submit a patch to the project:
- Fork the official repository.
- Create your feature branch:
git checkout -b my-new-feature
. - Commit your changes:
git commit -am 'Add some feature'
. - Push to the branch:
git push origin my-new-feature
. - Make sure all tests in the project are still passing, and add test coverage of new behavior as appropriate.
- Create a new pull request.
To release a new version:
- Update the project history in History.md, and commit.
- Update the version numbers in the PasswordTextBox-Control.nuspec file and in all AssemblyInfo.cs files, and commit.
- Build the NuGet package:
nuget pack PasswordTextBox-Control.nuspec
. - Publish the NuGet package:
nuget push PasswordTextBox-Control.X.Y.Z.nupkg
whereX.Y.Z
is the version you just built. - Tag the commit and push commits and tags.
Released under the MIT License.