Represents a Windows text box control.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
With the control, the user can enter text in an application. This control has additional functionality that is not found in the standard Windows text box control, including multiline editing and password character masking.
Typically, a control is used to display, or accept as input, a single line of text. You can use the Multiline and ScrollBars properties to enable multiple lines of text to be displayed or entered. Set the AcceptsTab and AcceptsReturn properties to true to enable greater text manipulation in a multiline control.
You can limit the amount of text entered into a control by setting the MaxLength property to a specific number of characters. 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. Use the CharacterCasing property to enable the user to type only uppercase, only lowercase, or a combination of uppercase and lowercase characters into the control.
To scroll the contents of the until the cursor (caret) is within the visible region of the control, you can use the ScrollToCaret method. To select a range of text in the text box, you can use the Select method.
To restrict text from being entered in a control, you can create an event handler for the KeyDown event in order to validate each character entered in the control. You can also restrict all entry of data in a control by setting the ReadOnly property to true.
Most of the functionality of the control is inherited from the TextBoxBase class.
Using the control with visual styles enabled will cause the incorrect handling of surrogate fonts.
Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows CE Platform Note: In Pocket PC applications, tabs in a single-line text box display as brackets, but display in the usual way when Multiline is set to true.
The following code example creates a multiline control with vertical scroll bars. This example uses the AcceptsTab, AcceptsReturn, and Dock properties to make the multiline text box control useful for creating text documents.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.