ComponentOne Input for WinForms
Using the C1Input Controls / Formatting Data
In This Topic
    Formatting Data
    In This Topic

    C1Input controls support a rich formatting model which enables developers to customize the appearance of a control’s text in almost any way imaginable. The main function of formatting is to display a string Text representation of a typed or stored Value.

    Formatting is controlled by the FormatType property, see Format Types for details. Its enumerated values define data will be formatted in the control. Some of the options correspond to .NET standard format specifiers for numeric and date-time types, for example, StandardNumber and LongDate, see Formatting Types in the .NET Framework documentation.

    One FormatType option, CustomFormat, corresponds to the case of a custom format specifier as defined in the .NET Framework documentation, the specifier itself is determined by the CustomFormat property. For example, CustomFormat property is set to "##,###.###" produces numbers with at most five digits before and three digits after decimal point. See Custom Format Specifiers for details.

    There is also a special FormatType option, UseEvent, which delegates the formatting to the Formatting event.

    The ability to represent NULL values (System.DBNull) is controlled by the NullText and EmptyAsNull properties.

    Sometimes you may find it useful to trim leading and/or trailing spaces when showing the formatted value. You can use the TrimStart and TrimEnd properties for that.

    It is possible to specify two different formats, one for display (when the control is read-only or is not in the edit mode), and another for edit mode, see Value and Text: Displaying, Validating, and Updating Values to find more information about edit mode.

    These two formatting modes are governed by the DisplayFormat and EditFormat properties. By default, both of them inherit from the control’s properties. To assign specific FormatType, CustomFormat or other formatting property (see FormatInfo class) for a specific mode, expand the DisplayFormat or EditFormat nodes, and change the (Inherit) flags and set the desired sub-property.

    See Also