Editable Text Controls: TextBoxBase

In addition to all of the controls that have a run-of-the-mill Text property, there are several controls whose sole purpose is to display editable text. The Label control displays text, but is read-only.

The TextBoxBase class provides a base class for three controls that allow the read-write display of text:


Displays text with no formatting other than the current Font of the control. Has a 64K character capacity limit.


A text box hosted in a DataGridTextBoxColumn control. Derives from TextBox.


Displays text with formatting.

Figure 12-1 shows the class hierarchy of the TextBoxBase class.

TextBoxBase class hierarchy

Figure 12-1. TextBoxBase class hierarchy

Properties and Methods

The TextBoxBase class has many properties and methods in addition to those inherited from Control. Many of the properties are listed in Table 12-1 and the methods in Table 12-4. Many of the most commonly used properties and methods are demonstrated in the examples that follow.

Table 12-1. TextBoxBase properties


Value type




Read/write. Applies to multiline TextBoxes and RichTextBoxes. If true, the Tab key is accepted as part of the text string, otherwise it moves the focus to the next control in the tab order. The default is false.



Read/write. If true (the default), the size of control is automatically adjusted ...

Get Programming .NET Windows Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.