Back to Devexpress

RepositoryItemTextEdit.PasswordChar Property

windowsforms-devexpress-dot-xtraeditors-dot-repository-dot-repositoryitemtextedit-05d0b6ad.md

latest4.3 KB
Original Source

RepositoryItemTextEdit.PasswordChar Property

Gets or sets the password character that appears instead of actual characters.

Namespace : DevExpress.XtraEditors.Repository

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DefaultValue('\0')]
[DXCategory("Behavior")]
public virtual char PasswordChar { get; set; }
vb
<DXCategory("Behavior")>
<DefaultValue(vbNullChar)>
Public Overridable Property PasswordChar As Char

Property Value

TypeDefaultDescription
Char'\0'

A character that appears instead of actual characters.

|

Remarks

You can mask the actual users’ input in a text editor in two ways:

Users cannot copy or cut text from an editor in password mode; the TextEdit.Cut and TextEdit.Copy methods will do nothing.

The MemoEdit and MemoExEdit editors, and editors without text input, do not support input masks.

The code sample below illustrates how to turn on/off the password mask.

csharp
buttonEdit1.ButtonClick += ButtonEdit1_ButtonClick;

private void ButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
    ButtonEdit edit = sender as ButtonEdit;
    edit.Properties.PasswordChar = (edit.Properties.PasswordChar == '*') ? '\0' : '*';
}
vb
Private buttonEdit1.ButtonClick += AddressOf ButtonEdit1_ButtonClick

Private Sub ButtonEdit1_ButtonClick(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Controls.ButtonPressedEventArgs)
    Dim edit As ButtonEdit = TryCast(sender, ButtonEdit)
    edit.Properties.PasswordChar = If(edit.Properties.PasswordChar = "*"c, ControlChars.NullChar, "*"c)
End Sub

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the PasswordChar property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-mvvm-expenses-app/CS/MVVMExpenses/Views/LoginView.cs#L17

csharp
InitializeComponent();
    PasswordTextEdit.Properties.PasswordChar = '*';
}

winforms-mvvm-expenses-app/VB/MVVMExpenses/Views/LoginView.vb#L20

vb
InitializeComponent()
    PasswordTextEdit.Properties.PasswordChar = "*"c
End Sub

See Also

UseSystemPasswordChar

RepositoryItemTextEdit Class

RepositoryItemTextEdit Members

DevExpress.XtraEditors.Repository Namespace