CoreSuite.PasswordBox
2.0.0
dotnet add package CoreSuite.PasswordBox --version 2.0.0
NuGet\Install-Package CoreSuite.PasswordBox -Version 2.0.0
<PackageReference Include="CoreSuite.PasswordBox" Version="2.0.0" />
<PackageVersion Include="CoreSuite.PasswordBox" Version="2.0.0" />
<PackageReference Include="CoreSuite.PasswordBox" />
paket add CoreSuite.PasswordBox --version 2.0.0
#r "nuget: CoreSuite.PasswordBox, 2.0.0"
#:package CoreSuite.PasswordBox@2.0.0
#addin nuget:?package=CoreSuite.PasswordBox&version=2.0.0
#tool nuget:?package=CoreSuite.PasswordBox&version=2.0.0
CoreSuite PasswordBox
CoreSuite.PasswordBox is a reusable Windows Forms password editor for .NET 8. It combines a borderless TextBox with a right-aligned action button and supports a password-replacement workflow that does not require an already stored password to be loaded into the control.
Features
- Password entry with system password masking.
- Embedded action button positioned on the right side.
- Customizable
ShowPasswordImage,HidePasswordImage, andChangePasswordImage. - No built-in images or GDI+ glyphs; the application defines the initial visual identity.
- Existing-password state without loading the real stored password.
- Fixed-length placeholder for already stored passwords.
- Context-sensitive action button that switches between change, show, and hide actions.
- Password replacement tracking through
PasswordChanged. - Cancelable replacement workflow.
AcceptPasswordChangehelper to clear the plaintext replacement value after persistence.- Read-only mode.
- Configurable reveal behavior, button width, image alignment, and mask length.
- Customizable border colors and localizable tooltips.
F2starts password replacement andEsccancels it.- Accessibility metadata for the embedded action button.
- Complete XML documentation.
Installation
Install-Package CoreSuite.PasswordBox
Or:
dotnet add package CoreSuite.PasswordBox
Configuring action images
No image is defined by default. Configure them in the Windows Forms Designer or in code:
PasswordBox1.ShowPasswordImage = My.Resources.ShowPassword
PasswordBox1.HidePasswordImage = My.Resources.HidePassword
PasswordBox1.ChangePasswordImage = My.Resources.ChangePassword
The control changes the image automatically according to its current state.
| State | Property |
|---|---|
| Password hidden and editable | ShowPasswordImage |
| Password visible and editable | HidePasswordImage |
| Existing password defined | ChangePasswordImage |
The supplied images are not disposed by PasswordBox; ownership remains with the application or designer resources.
Basic usage
PasswordBox1.PasswordDefined = False
PasswordBox1.PlaceholderText = "Enter password"
When saving:
If PasswordBox1.PasswordChanged Then
EmailCredentialsService.SavePassword(PasswordBox1.Password)
PasswordBox1.AcceptPasswordChange()
End If
Existing password workflow
PasswordBox1.PasswordDefined = True
The real stored password does not need to be loaded into the control.
Stored: [ •••••••• ][ change ]
Editing: [ new password ][ show ]
Visible: [ new password ][ hide ]
After successful persistence:
PasswordBox1.AcceptPasswordChange(passwordDefined:=True)
To cancel:
PasswordBox1.CancelPasswordChange()
Main properties
| Property | Description |
|---|---|
PasswordDefined |
Indicates whether the application already has a stored password. |
Password |
Returns the replacement password currently entered by the user. |
PasswordChanged |
Indicates whether the replacement password has been modified. |
IsEditingPassword |
Indicates whether replacement mode is active. |
IsPasswordVisible |
Indicates whether the replacement password is visible. |
ReadOnly |
Disables editing and replacement. |
AllowPasswordReveal |
Enables or disables password reveal. |
ShowActionButton |
Shows or hides the action button. |
ActionButtonWidth |
Sets the button width. |
ActionButtonImageAlign |
Sets the image alignment in the button. |
ShowPasswordImage |
Image used for the show action. |
HidePasswordImage |
Image used for the hide action. |
ChangePasswordImage |
Image used for the change action. |
DefinedPasswordMaskLength |
Sets the fixed stored-password placeholder length. |
MaxLength |
Sets maximum password length. |
TextAlign |
Sets password text alignment. |
ShortcutsEnabled |
Enables standard text editing shortcuts. |
PlaceholderText |
Sets the empty-field placeholder. |
BorderColor |
Sets normal border color. |
FocusedBorderColor |
Sets focused border color. |
DisabledBorderColor |
Sets disabled border color. |
ChangePasswordToolTipText |
Sets the change action tooltip. |
ShowPasswordToolTipText |
Sets the show action tooltip. |
HidePasswordToolTipText |
Sets the hide action tooltip. |
Main methods
| Method | Description |
|---|---|
BeginPasswordChange() |
Starts password replacement mode. |
CancelPasswordChange() |
Cancels replacement. |
AcceptPasswordChange() |
Marks the replacement as persisted and clears plaintext. |
SetPassword() |
Sets a replacement password programmatically. |
ClearPassword() |
Clears the replacement editor. |
SelectAllPassword() |
Selects the active replacement password. |
FocusPassword() |
Focuses the password editor. |
Events
| Event | Description |
|---|---|
PasswordValueChanged |
Raised when the replacement password changes. |
PasswordEditStarted |
Raised when replacement begins. |
PasswordEditCanceled |
Raised when replacement is canceled. |
PasswordVisibilityChanged |
Raised when password visibility changes. |
Security notes
PasswordBox can represent an existing password without receiving the existing plaintext value. The fixed placeholder length does not expose the actual password length.
A password mask is visual protection only and does not encrypt a password while it is being edited.
Requirements
- .NET 8
- Windows Forms
net8.0-windows
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0-windows7.0 is compatible. net9.0-windows was computed. net10.0-windows was computed. |
-
net8.0-windows7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Refactored PasswordBox to inherit directly from TextBox, providing native text editing behavior while preserving the embedded customizable image action button, password-defined state, replacement workflow, show/hide functionality, fixed-length stored-password placeholder, change tracking, cancellation, acceptance flow, accessibility support and complete XML documentation. Removed the previous UserControl-based layout and custom border properties.