TextBox
Last updated
Last updated
The TextBox control allows users to enter a string. It supports highlighting, copy/paste, selection with mouse and keyboard, and CTRL key for performing operations on entire words.
The following code creates a TextBox.
Selection can be performed programmatically or by the user using the cursor.
The SelectionLength
property can be used to determine if any text is selected. The following code shows how to output the selected characters:
The SelectionStart
and SelectionLength
proerties can be modified to change the visual selection. For example, the following selects the first 5 letters:
The entire text can be selected as shown in the following code:
Selection can also be performed by the user. Double-clicking the text box selects all text.
A push+drag with the mouse selects the text between the start and the current location of the drag.
Holding down the shift key and pressing the arrow keys adjusts the selection.
The TextWrapping property can be used to set whether the TextBox wraps text. By default this value is set to TextWrapping.NoWrap
which means the text does not wrap, but instead extends horizontally.
If TextWrapping is set to `TextWrapping.Wrap, then text wraps to multiple lines. Note that usually this is combined with a taller text box so that multiple lines display properly.