How can I use the DevExpress WinForms TextEdit as a password entry (with asterisks)?
Solution 1
Use RepositoryItemTextEdit.PasswordChar Property
The TextEdit has a
Properties.PasswordChar
property, which is empty by default. By >setting some char there (for example, *), you will enable the functionality you require.
Password mode allows you to mask the editor's text. You can activate password mode in two ways:
Set the
UseSystemPasswordChar
property totrue
. The editor's text will be masked as follows:-
Set the
PasswordChar
property toany valid character
. This character will be used to mask the editor's text.For instance, if the
PasswordChar
property is set to"*"
, an editor will work as you want to do.
Note: The PasswordChar
property is ignored if the RepositoryItemMemoEdit.UseSystemPasswordChar
property is set to true
.
Pragmatically you can set it as:
TextEdit.Properties.PasswordChar = '*'
And From GUI go to Properties section and then further look for the Properties
there you will get the PasswordChar
property, Set it to valid character as per documentation. e.g. *
.
Solution 2
Set PasswordChar
property of TextBox
to the character which should be visible in the text box instead of the real text.
For example:
textBox.PasswordChar = '*';
Solution 3
You can achieve the same with the regular TextBox control if you set the TextBox.UseSystemPasswordChar to true. This setting will also cause the TextBox control to display a tooltip warning if your CapsLock is on, just like in the Windows Login screen.
Stephen Oberauer
Senior .NET developer / former tech lead (C#, SQL, Angular, Vue.js, WPF, JavaScript, HTML, etc., etc., etc...) Other interests: Writing (The Mischievous Nerd's Guide to World Domination, Transpolitica, blog), Video Making (Especially 3D - stereoscopic), Skateboarding, AI, VR, Music (Mainly electric guitar) Very interested in the future, especially the future of technologies such as AI and VR. Also very interested in initiatives to make the world run more intelligently. Wouldn't it be nice if the world ran on a system that worked as well as stackoverflow.com?
Updated on June 07, 2022Comments
-
Stephen Oberauer almost 2 years
According to http://www.devexpress.com/Products/NET/Controls/WinForms/Editors/editors/textEdit.xml one can use the Developer Express TextEdit control to input a password and hide the characters. Can anyone explain to me how to do this? It seems like it should be really simple.