How to show a text as hidden using c# - c#

I am developping in C#.
I need to capture a password written inside a Text Box, but would like to not show the password that is being typed, showing instead **** or any other character to hide the password.
How can I do that? I'm sure it's by modifying an attribute, but can't find which one.

http://msdn.microsoft.com/en-us/library/d3223ht2.aspx
set the PasswordChar property of the textbox

Set the PasswordChar property.

There is a property on the TextBox class called "UseSystemPasswordChar" (assuming winforms) that let you do this.

To use your own custom character:
http://msdn.microsoft.com/en-us/library/system.windows.forms.textbox.passwordchar.aspx
To use the system default character:
http://msdn.microsoft.com/en-us/library/system.windows.forms.textbox.usesystempasswordchar.aspx
textBox1.UseSystemPasswordChar = true;
//or
textBox1.PasswordChar = '%';

Related

C# no PasswordChar field missing from textbox

Im writing a c# program using vs2015, however there is no option in the properties field of the textbox for PasswordChar. Im trying to make it so the textbox would show '*' instead of the inputted text.
I have tried manually coding in mytxtbox.PasswordChar = '*' however I get the error "TextBox does not contain a definition for PasswordChar"
Thanks in adavance.
You should be using PasswordBox instead of TextBox.
Note that you will need to use an attached behavior to enable binding of the value to a ViewModel property as described in this tutorial.

make the Text of Textbox invisible

Is it possible some how to make the Text of the Textbox invisible or to hide it so the user can't see it , yet it get's the input/keys from the user?
It's better to rely on the built-in capabilities.
For instance, consider to use the TextBox.PasswordChar property.
You can set ForeColor = BackColor
Paste in your Properties -> Behavior -> PasswordChar symbol you need, empty blanks works too.

How to set mode Password for TextBox control wpf without passwordbox?

I need to USE hidden inserted symbols in my textbox and show "password" like "*******".
But after this I will use inserted password for login. I can not use PasswordBox because it don't have need touch event.
How do I do it ?
You should check out this answer to a similar question:
https://stackoverflow.com/a/481097/4192732
You basically need a third-party extension to avoid using the passwordbox, as there are no first-party methods of masking a WPF textbox.

putting "*" values in a dialog box C# forms

I am using the simple Dialog box given in the following link as a crude (that's all I need) password input box:
http://www.csharp-examples.net/inputbox-class/
How do I set the text to display **** instead of the password?
In that control you have a TextBox, set the PasswordChar property of the textbox to *.
Also see: How to: Create a Password Text Box with the Windows Forms TextBox Control
In your control's show method, after defining that textbox, add:
textBox.PasswordChar = '*';
use like this
textBox1.PasswordChar = '*';
From How to: Create a Password Text Box with the Windows Forms TextBox Control
To create a password text box
Set the PasswordChar property of the TextBox control to a specific character. The PasswordChar property specifies the character displayed
in the text box. For example, if you want asterisks displayed in the
password box, specify * for the PasswordChar property in the
Properties window. Then, regardless of what character a user types in
the text box, an asterisk is displayed.
// The password character is an asterisk.
textBox1.PasswordChar = '*';
From TextBox.PasswordChar property
Gets or sets the character used to mask characters of a password in a
single-line TextBox control.
textBox1.PasswordChar = '*';
Just set that property on your text box and it should work.
From the property window in windows forms

Display string item in windows - C#

I have a string with dots and carriage returns etc... totally its a big string!
I want to show it in a windows form, so i wanted to know which one will be the good control to show it upon.
Thanks in advance,
Ravi Naik.
Use a TextBox with the Multiline property set to True.
Alternatively you can use a RichTextBox control or a WebBrowser control where you set the DocumentText property.
I would probably use a RichTextBox for displaying the plain text. Check out the AppendText method.

Categories