Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
IsValidInput Property

TypeValidationEventArgs.IsValidInput Property

Gets a value indicating whether the formatted input string was successfully converted to the validating type.

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

public bool IsValidInput { get; }

Property Value

Type: System.Boolean
true if the formatted input string can be converted into the type specified by the ValidatingType property; otherwise, false.

The IsValidInput property indicates the success of the Parse method found in the Type represented by the ValidatingType property. This type must contain Parse method(s) having one or both of the following signatures:

public static Object Parse(string)

public static Object Parse(string, IFormatProvider)

Parse is called before the MaskedTextBox control raises the TypeValidationCompleted event. This method is invoked with the contents, minus the prompt characters, of the Text property of the MaskedTextBox class. If successful, it returns the converted object; otherwise, it returns null.

For more information about the type validation process, see the TypeValidationCompleted event. For an example of how to implement parsing on a custom data type, see MaskedTextBox Control Sample.

The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the MaskedTextBox.TypeValidationCompleted event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing MessageBox.Show with Console.WriteLine or appending the message to a multiline TextBox.

To run the example code, paste it into a project that contains an instance of type MaskedTextBox named MaskedTextBox1. Then ensure that the event handler is associated with the MaskedTextBox.TypeValidationCompleted event.

private void MaskedTextBox1_TypeValidationCompleted(Object sender, TypeValidationEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "Cancel", e.Cancel );
messageBoxCS.AppendFormat("{0} = {1}", "IsValidInput", e.IsValidInput );
messageBoxCS.AppendFormat("{0} = {1}", "Message", e.Message );
messageBoxCS.AppendFormat("{0} = {1}", "ReturnValue", e.ReturnValue );
messageBoxCS.AppendFormat("{0} = {1}", "ValidatingType", e.ValidatingType );
MessageBox.Show(messageBoxCS.ToString(), "TypeValidationCompleted Event" );

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

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

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

© 2015 Microsoft