# Programmatic Formatting, Parsing, and Validation

Learn about features like Programmatic Formatting, Parsing, and Validation in ComponentOne Input for WinForms.

## Content



If standard and custom format specifiers are not enough, you can format values in code in the [Formatting](/componentone/api/win/online-input/dotnet-framework-api/C1.Win.C1Input.4.8/C1.Win.C1Input.C1TextBox.Formatting.html) event by setting the [FormatType](/componentone/api/win/online-input/dotnet-framework-api/C1.Win.C1Input.4.8/C1.Win.C1Input.C1TextBox.FormatType.html) property to [UseEvent](/componentone/api/win/online-input/dotnet-framework-api/C1.Win.C1Input.4.8/C1.Win.C1Input.FormatTypeEnum.html), see [Formatting Data](/componentone/docs/win/online-input/usingthec1inputcontr/formattingdata). In your formatting code, you can use the standard **C1Input** formatting as a helper or for any other purposes, calling the [Format](/componentone/api/win/online-input/dotnet-framework-api/C1.Win.C1Input.4.8/C1.Win.C1Input.FormatInfo.Format.html) method.

Parsing can also be done in event code, in the [Parsing](/componentone/api/win/online-input/dotnet-framework-api/C1.Win.C1Input.4.8/C1.Win.C1Input.C1TextBox.Parsing.html) event, by setting the [FormatType](/componentone/api/win/online-input/dotnet-framework-api/C1.Win.C1Input.4.8/C1.Win.C1Input.ParseInfo.FormatType.html) property to UseEvent. You can use standard **C1Input** parsing routines in your code if you need them, with the following [ParseInfo](/componentone/api/win/online-input/dotnet-framework-api/C1.Win.C1Input.4.8/C1.Win.C1Input.ParseInfo.html) methods: [Parse](/componentone/api/win/online-input/dotnet-framework-api/C1.Win.C1Input.4.8/C1.Win.C1Input.ParseInfo.Parse.html), [ParseFixed](/componentone/api/win/online-input/dotnet-framework-api/C1.Win.C1Input.4.8/C1.Win.C1Input.ParseInfo.ParseFixed.html), [ParseFloat](/componentone/api/win/online-input/dotnet-framework-api/C1.Win.C1Input.4.8/C1.Win.C1Input.ParseInfo.ParseFloat.html), [ParseInteger](/componentone/api/win/online-input/dotnet-framework-api/C1.Win.C1Input.4.8/C1.Win.C1Input.ParseInfo.ParseInteger.html), [ParseBoolean](/componentone/api/win/online-input/dotnet-framework-api/C1.Win.C1Input.4.8/C1.Win.C1Input.ParseInfo.ParseBoolean.html) and [ParseDateTime](/componentone/api/win/online-input/dotnet-framework-api/C1.Win.C1Input.4.8/C1.Win.C1Input.ParseInfo.ParseDateTime.html).

Some useful methods for edit mask management can be found in the [MaskInfo](/componentone/api/win/online-input/dotnet-framework-api/C1.Win.C1Input.4.8/C1.Win.C1Input.MaskInfo.html) class.

When you need to synchronize the [Value](/componentone/api/win/online-input/dotnet-framework-api/C1.Win.C1Input.4.8/C1.Win.C1Input.C1TextBox.Value.html) property with the text currently entered by the user, call the [UpdateValueWithCurrentText](/componentone/api/win/online-input/dotnet-framework-api/C1.Win.C1Input.4.8/C1.Win.C1Input.C1TextBox.UpdateValueWithCurrentText.html) method. Normally, this synchronization is done automatically when the control loses focus, but in certain situations you may find necessary to call this method and force the Value update. Updating Value involves parsing the input text, validating, and updating the Value property, see [Value and Text: Displaying, Validating, and Updating Values](/componentone/docs/win/online-input/usingthec1inputcontr/valueandtextdisplayi). You can also perform the first two phases, parsing and validation without changing the Value, using the methods [ParseContent](/componentone/api/win/online-input/dotnet-framework-api/C1.Win.C1Input.4.8/C1.Win.C1Input.C1TextBox.ParseContent.html) and [CheckValidationResult](/componentone/api/win/online-input/dotnet-framework-api/C1.Win.C1Input.4.8/C1.Win.C1Input.C1TextBox.CheckValidationResult.html).

## See Also

[Error Handling](/componentone/docs/win/online-input/usingthec1inputcontr/errorhandling)