Short question here:
In .Net 4.0 Winforms, how do I use the PasswordChar
property of a Textbox
to show a common black dot as a character? Is there perhaps some font I can use that has this as a character?
If I use 'UseSystemPasswordChar = true
' it shows an asterisk (*).
One more solution to use this Unicode black circle >>
Then select
Arial font
and choose theBlack circle
copy it and paste it intoPasswordChar
property of the textbox.That's it....
You can use this one: • You can type it by pressing Alt key and typing 0149.
I was also wondering how to store it cleanly in a variable. As using
is not very good practice (I guess). I found out the following way of storing it in a variable
or even cleaner
https://msdn.microsoft.com/en-us/library/aa664669%28v=vs.71%29.aspx
same for strings
https://msdn.microsoft.com/en-us/library/362314fe.aspx
Below are some different ways to achieve this. Pick the one suits you
In fonts like 'Tahoma' and 'Times new Roman' this common password character '●' which is called 'Black circle' has a unicode value 0x25CF. Set the PasswordChar property with either the value 0x25CF or copy paste the actual character itself.
If you want to display the Black Circle by default then enable visual styles which should replace the default password character from '*' to '●' by default irrespective of the font.
Another alternative is to use 'Wingdings 2' font on the TextBox and set the password character to 0x97. This should work even if the application is not unicoded. Refer to charMap.exe to get better idea on different fonts and characters supported.
Use the Unicode Character 'BLACK CIRCLE' (U+25CF) http://www.fileformat.info/info/unicode/char/25CF/index.htm
To cut and paste: ●