Export (0) Print
Expand All

MaskedTextBox.RejectInputOnFirstFailure Property

Gets or sets a value indicating whether the parsing of user input should stop after the first invalid character is reached.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

member RejectInputOnFirstFailure : bool with get, set

Property Value

Type: System.Boolean
true if processing of the input string should be terminated at the first parsing error; otherwise, false if processing should ignore all errors. The default is false.

Sometimes the user will enter several characters into a MaskedTextBox in a single input operation, typically by copying and pasting a string. If the entire string only contains valid characters, according to their paste position in the input mask, then the entire operation will succeed. However, when a parsing error occurs, the behavior of MaskedTextBox depends on the value of RejectInputOnFirstFailure, as follows:

  • If this property is true, then processing of the input string stops at the invalid character. All subsequent characters are ignored. A single MaskInputRejected event is raised.

  • If this property is false, then the invalid character is rejected, but parsing continues with the next character in the input string. A MaskInputRejected event is raised for every invalid character in the input string.

The ResetOnPrompt, ResetOnSpace and SkipLiterals properties can also influence the interpretation of the user input.

If the IsOverwriteMode property is false, then any characters already in the input mask to the right of the insertion point will be displaced by the accepted number of characters. This shifting may cause additional parsing errors.

A pasting operation can be mimicked programmatically by setting the SelectedText property.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft