2

Possible Duplicate:
Which passwordchar shows a black dot (•) in a winforms textbox?
Unicode encoding for string literals in C++11

I want to use code to reveal the password or make it a dot like •

textBoxNewPassword.PasswordChar = (char)0149; 

How can I achieve this?

3
  • its not a duplicate. I am trying 2 do it in code. The other guy did it using the properties in the Designer Commented Nov 5, 2012 at 17:35
  • 1
    You can try textBoxNewPassword.PasswordChar ='\u2022'. Commented Nov 5, 2012 at 17:42
  • @CocoaDev What difference does it make? Just copy/paste the character. Commented Nov 5, 2012 at 19:05

5 Answers 5

7

http://blog.billsdon.com/2011/04/dot-password-character-c/ suggests '\u25CF';

Or try copy pasting this •

Sign up to request clarification or add additional context in comments.

Comments

7

(not exactly an answer to your question, but still)

You can also use the UseSystemPasswordChar property to select the default password character of the system:

textBoxNewPassword.UseSystemPasswordChar = true; 

Often mapped to the dot, and always creating a consistent user experience.

Comments

1

You need to look into using the PasswordBox control and setting the PasswordChar as *.

Example:

textBox1.PasswordChar = '*'; // Set a text box for password input 

Comments

1

Wikipedia has a table of similar symbols.

In C#, to make a char literal corresponding to U+2022 (for example) use '\u2022'. (It's also fine to cast an integer literal as you do in your question, (char)8226)


Late addition. The reason why your original approach was unsuccessful, is that the value 149 you had is not a Unicode code point. Instead it comes from Windows-1252, and Windows-1252 is not a subset of Unicode. In Unicode, decimal 149 means the C1 control code "Message Waiting".

You could translate from Windows-1252 with:

textBoxNewPassword.PasswordChar = Encoding.GetEncoding("Windows-1252").GetString(new byte[] { 149, })[0]; 

but it is easier to use the Unicode value directly of course.


In newer versions of .NET, you need to call:

Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); 

before you can use something like Encoding.GetEncoding("Windows-1252").

Comments

0
textBoxNewPassword.PasswordChar = '\u25CF'; 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.