With the TextBox 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 TextBox 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 TextBox control.
You can limit the amount of text entered into a TextBox control by setting the MaxLength property to a specific number of characters. 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. Use the CharacterCasing property to enable the user to type only uppercase, only lowercase, or a combination of uppercase and lowercase characters into the TextBox control.
To restrict text from being entered in a TextBox 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 TextBox control by setting the ReadOnly property to true.
Note |
|---|
| Most of the functionality of the TextBox control is inherited from the TextBoxBase class. |
Note |
|---|
| Using the TextBox 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.