Reputation: 11
How do I enter a unicode character (it needs to be the equivalent of ascii character 254, a solid square centered box) as the password character in a textbox?
I need to do this in code, for example textbox.passwordchar = ????????
Thanks,
Upvotes: 1
Views: 1959
Reputation: 15354
textBox_Name.PasswordChar='■';
When you want to use any of the unicode char simply Press ALT & then ascii value of that key while pressing ALT key
e.g.
■ = ALT+254
♪ = ALT+269
A = ALT+65
a = ALT+97
NOTE: numeric keys must be pressed from NumPad
Upvotes: 1
Reputation: 1058
this.tePassword.Properties.PasswordChar = (char)254; results in a character that looks similar to a b - it's definitely not ascii 254.
Upvotes: 0
Reputation: 263117
Use the TestBox.PasswordChar property. Assuming you want UNICODE
character BLACK SQUARE (U+25A0), either do:
yourTextBox.PasswordChar = '■';
Or:
yourTextBox.PasswordChar = '\u25a0';
Upvotes: 2
Reputation: 16718
I believe you should be able to just assign a constant Unicode character, as described in this MSDN article...
Upvotes: 0
Reputation: 888077
The same way you enter any other character.
C# source files can contain Unicode characters in identifiers and strings.
You can also use the escape sequence "\uxxxx"
to use a Unicode character by (hex) codepoint.
Upvotes: 2