A TextBox control is used to display, or accept as input, a single line of text. This control has additional functionality that is not found in the standard Windows text box control, including multiline editing and password character masking.

A text box object is used to display text on a form or to get user input while a C# program is running. In a text box, a user can type data or paste it into the control from the clipboard.
For displaying a text in a TextBox control , you can code like this
textBox1.Text = "http://csharp.net-informations.com";
You can also collect the input value from a TextBox control to a variable like this way
string var;var = textBox1.Text;
When a program wants to prevent a user from changing the text that appears in a text box, the program can set the controls Read-only property is to True.
textBox1.ReadOnly = true;
You can use the Multiline and ScrollBars properties to enable multiple lines of text to be displayed or entered.
textBox1.Multiline = true;
TextBox controls can also be used to accept passwords and other sensitive information. You can use the PasswordChar property to mask characters entered in a single line version of the control
textBox1.PasswordChar = '*';
The above code set the PasswordChar to * , so when the user enter password then it display only * instead of typed characters.
From the following C# source code you can see some important property settings to a TextBox control.
using System;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
textBox1.Width = 250;
textBox1.Height = 50;
textBox1.Multiline = true;
}
private void button1_Click(object sender, EventArgs e)
{
string var;
var = textBox1.Text;
MessageBox.Show(var);
}
}
}