System.Windows.Forms.TextBoxBase.MaxLength Property

Gets or sets the maximum number of characters the user can type or paste into the text box control.

Syntax

[System.ComponentModel.Localizable(true)]
[System.ComponentModel.DefaultValue(32767)]
public virtual int MaxLength { set; get; }

Value

Documentation for this section has not yet been entered.

Remarks

You can use this property to restrict the length of text entered in the control for values such as postal codes and telephone numbers, or to restrict the length of text entered when the data is to be entered in a database. You can limit the text entered into the control to the maximum length of the corresponding field in the database.

Note:

In code, you can set the value of the TextBoxBase.Text property to a value that has a length greater than the value specified by the TextBoxBase.MaxLength property. This property only affects text entered into the control at run time.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0
Since: .NET 2.0