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;

 
C# Controls.
ButtonControl
ComboBox Control
CheckBox Control
ListBox Control
ListView Control
Label Control
LinkLabel Control
MenuStrip Control
Mdi Control
RadioButton Control
RichText Box
SystemSpeech API
SystemIO Images
TextBox Control
TreeView Control
WebBrowser Control
Programming Books
Related.
DevComponents
Infragistics
Visual Studio
ASP.NET
Top of page
Copy Right 2006 SpeakComputers.com, All Rights Reserved.

Home |  XBOX Console and Games | Windows Vista | Text to Speech | Learn HTML | Programming with C# | AntiVirus Software | Internet Security
Site Map | Contact SpeakComputers.com | Privacy Policy | Web Directory