--- title: "TextBox Control Overview" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" - "cpp" f1_keywords: - "TextBox" helpviewer_keywords: - "TextBox control [Windows Forms], about TextBox controls" - "text boxes [Windows Forms], adding" ms.assetid: d1a9c7f5-fa53-480a-a75c-158f8649ea2f --- # TextBox Control Overview (Windows Forms) Windows Forms text boxes are used to get input from the user or to display text. The control is generally used for editable text, although it can also be made read-only. Text boxes can display multiple lines, wrap text to the size of the control, and add basic formatting. The control provides a single format style for text displayed or entered into the control. To display multiple types of formatted text, use the control. For more information, see [RichTextBox Control Overview](richtextbox-control-overview-windows-forms.md). ## Working with the TextBox Control The text displayed by the control is contained in the property. By default, you can enter up to 2048 characters in a text box. If you set the property to `true`, you can enter up to 32 KB of text. The property can be set at design time with the Properties Window, at run time in code, or by user input at run time. The current contents of a text box can be retrieved at run time by reading the property. The following code example sets text in the control at run time. The `InitializeMyControl` procedure will not execute automatically; it must be called. ```vb Private Sub InitializeMyControl() ' Put some text into the control first. TextBox1.Text = "This is a TextBox control." End Sub ``` ```csharp private void InitializeMyControl() { // Put some text into the control first. textBox1.Text = "This is a TextBox control."; } ``` ```cpp private: void InitializeMyControl() { // Put some text into the control first. textBox1->Text = "This is a TextBox control."; } ``` ## See also - - [How to: Control the Insertion Point in a Windows Forms TextBox Control](how-to-control-the-insertion-point-in-a-windows-forms-textbox-control.md) - [How to: Create a Password Text Box with the Windows Forms TextBox Control](how-to-create-a-password-text-box-with-the-windows-forms-textbox-control.md) - [How to: Create a Read-Only Text Box](how-to-create-a-read-only-text-box-windows-forms.md) - [How to: Put Quotation Marks in a String](how-to-put-quotation-marks-in-a-string-windows-forms.md) - [How to: Select Text in the Windows Forms TextBox Control](how-to-select-text-in-the-windows-forms-textbox-control.md) - [How to: View Multiple Lines in the Windows Forms TextBox Control](how-to-view-multiple-lines-in-the-windows-forms-textbox-control.md) - [TextBox Control](textbox-control-windows-forms.md)