90

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 (*).

ridoy
  • 6,274
  • 2
  • 29
  • 60
Edwin de Koning
  • 14,209
  • 7
  • 56
  • 74

6 Answers6

160

You can use this one:

You can type it by holding Alt and typing 25CF.


Alternately, you may use this smaller one:

You can type it by holding Alt and typing 2022.

Addison
  • 7,322
  • 2
  • 39
  • 55
Giorgi
  • 30,270
  • 13
  • 89
  • 125
  • 3
    Just in case anyone's interested, on a mac it's Alt + 8 – Benj May 04 '19 at 08:30
  • If you're stuggling to type hexadecimal unicode characters with alt key in your application - [Can't type Unicode because of keyboard shortcuts](https://superuser.com/q/864944/374397) – RBT Aug 02 '21 at 07:08
70

Use the Unicode Character 'BLACK CIRCLE' (U+25CF) http://www.fileformat.info/info/unicode/char/25CF/index.htm

To copy and paste: ●

Delrius Euphoria
  • 14,910
  • 3
  • 15
  • 46
Mark Menchavez
  • 1,651
  • 12
  • 15
20

I was also wondering how to store it cleanly in a variable. As using

char c = '•';

is not very good practice (I guess). I found out the following way of storing it in a variable

char c = (char)0x2022;// or 0x25cf depending on the one you choose

or even cleaner

char c = '\u2022';// or "\u25cf"

https://msdn.microsoft.com/en-us/library/aa664669%28v=vs.71%29.aspx

same for strings

string s = "\u2022";

https://msdn.microsoft.com/en-us/library/362314fe.aspx

Wasabi
  • 456
  • 1
  • 4
  • 12
10

One more solution to use this Unicode black circle >>

Start >> All Programs >> Accessories >> System Tools >> Character Map

Then select Arial font and choose the Black circle copy it and paste it into PasswordChar property of the textbox.

That's it....

Lennart Regebro
  • 167,292
  • 41
  • 224
  • 251
dotnetmaster
  • 101
  • 1
  • 2
5

Below are some different ways to achieve this. Pick the one suits you

  1. 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.

  2. 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.

  3. 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 compatible with unicode. Refer to charMap.exe to get better idea on different fonts and characters supported.

someuser
  • 9
  • 4
V M Rakesh
  • 324
  • 3
  • 3
3

Instead of copy/paste a unicode character or setting it in the code-behind you could also change the properties of the TextBox. Simply set UseSystemPasswordChar to True and everything will be done for you by the Framework. Like this:

this.txtPassword.UseSystemPasswordChar = true;
someuser
  • 9
  • 4
  • This is usually the best solution if you're building a password input field. In my case however, I just need a representation of a password that isn't shown to the user so I needed the character itself to repeat a few times. – ThaJay Feb 13 '23 at 14:33