TextBox Control.
The TextBox control is typically used by the user to enter some text into part of
the application or form. More commonly used to enter small text data, it can be
used with the multiline feature for longer text fields. You can also limit the text
length field
as well as use the control for special fields as passwords. The text
entered in the textbox field can be used to update a database field, written to
new file or update an exiting file. It is a control that is found in most if not
all software programs.

Namespace: System.Windows.Forms
Assembly: Systems.Windows.Forms.dll
using System.Windows.Forms;
Calling: System.Windows.Forms.TextBox
Creating a new System.Windows.Forms.TextBox control.
TextBox textBox1 = new TextBox();
Adding the TextBox control to a Windows form.
this.Controls.Add(textBox1);
Placing the TextBox on the form at a specific location.
textBox1.Location = new Point(50, 50);
Assigning a text value to a TextBox control.
textBox1.Text = "Enter";
Assigning a TextChanged event to the TextBox control.
textBox1.TextChanged+=new EventHandler(textBox1_Click);
Responding to the TextChanged event.
private void textBox1_TextChanged(object sender, EventArgs e)
{
//The MessageBox is part of the System.Windows.Forms namespace.
MessageBox.Show("HelloWorld");
}
Changing the background color of the TextBox control.
textBox1.BackColor = System.Drawing.Color.Red;
To disable the TextBox control.
textBox1.Enabled = false;
Here the TextBox control is still visible (partially faded) but will not respond
to any events. To re-enable the TextBox control you would set the Enabled property
to true. When adding the TextBox control the default setting is for the control to
be Enabled.
To set the TextBox control to multiline.
this.textBox1.Multiline = true;
To set the scrollbar values.
this.textBox1.ScrollBars = ScrollBars.Both;
|
|