ComponentOne Input for WinForms
Programmatic Formatting, Parsing, and Validation
Using the C1Input Controls > Programmatic Formatting, Parsing, and Validation

If standard and custom format specifiers are not enough, you can format values in code in the Formatting event by setting the FormatType property to UseEvent, see Formatting Data. In your formatting code, you can use the standard C1Input formatting as a helper or for any other purposes, calling the Format method.

Parsing can also be done in event code, in the Parsing event, by setting the FormatType property to UseEvent. You can use standard C1Input parsing routines in your code if you need them, with the following ParseInfo methods: Parse, ParseFixed, ParseFloat, ParseInteger, ParseBoolean and ParseDateTime.

Some useful methods for edit mask management can be found in the MaskInfo class.

When you need to synchronize the Value property with the text currently entered by the user, call the UpdateValueWithCurrentText 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. You can also perform the first two phases, parsing and validation without changing the Value, using the methods ParseContent and CheckValidationResult.

See Also