Input for WinForms | ComponentOne
Data Formatting / Format Types
In This Topic
    Format Types
    In This Topic

    By default (FormatType property is set to DefaultFormat), the Text is obtained by applying the standard ToString() method of the current DataType to the typed Value (more exactly, if the type has a type converter, TypeConverter.ToString() is used). This conversion (as all others) uses the regional settings provided by the CultureInfo property.

    Formatting is controlled by the FormatType property. Its enumerated values define the method of formatting values. Some of the options correspond to standard format specifiers for numeric and date-time types, for example, the StandardNumber and LongDate formats, for more information see Formatting Types in the .NET Framework documentation. One 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. There is also an option delegating formatting to code in an event. The following table describes the list of available options:

    Formatting Option Description
    DefaultFormat Conversion using TypeConverter.ConvertToString().
    UseEvent Conversion performed by user code in the Formatting (or Parsing) event.
    CustomFormat Formatting uses the string assigned to the CustomFormat property. Parsing uses NumberStyle, DateTimeStyle, and CustomFormat properties.
    GeneralNumber The number is converted to the most compact decimal form, using fixed point or scientific notation.
    Currency The number is converted to a string that represents a currency amount.
    FixedPoint The number is converted to a string of the form "-ddd.ddd…" where each 'd' indicates a digit (0-9). The string starts with a minus sign if the number is negative. The numeric precision is given by the property NumberFormatInfo.NumberDecimalDigits of the specified culture.
    StandardNumber The number is converted to a string of the form "-d,ddd,ddd.ddd…", where each 'd' indicates a digit (0-9). The string starts with a minus sign if the number is negative. Thousand separators are inserted between each group of three digits to the left of the decimal point. The numeric precision is given by the property NumberFormatInfo.NumberDecimalDigits of the specified culture.
    Percent The number is converted to a string that represents a percent as defined by the NumberFormatInfo.PercentNegativePattern property or the NumberFormatInfo.PercentPositivePattern property. If the number is negative, the string produced is defined by the PercentNegativePattern and starts with a minus sign. The converted number is multiplied by 100 in order to be presented as a percentage. The default numeric precision given by NumberFormatInfo is used.
    Scientific The number is converted to a string of the form "-d.ddd…E+ddd" or "-d.ddd…e+ddd", where each 'd' indicates a digit (0-9). The string starts with a minus sign if the number is negative. One digit always precedes the decimal point. The exponent always consists of a plus or minus sign and a minimum of three digits. The exponent is padded with zeros to meet this minimum, if required.
    RoundTrip The round-trip specifier guarantees that a numeric value converted to a string will be parsed back into the same numeric value. This format is supported by floating-point types only.
    Integer Displays number as a string that contains the value of the number in Decimal (base 10) format. This format is supported for integral types only.
    Hexadecimal The number is converted to a string of hexadecimal digits. This format is supported for integral types only.
    YesNo Converts to Boolean and shows No for False, Yes for True.
    TrueFalse Converts to Boolean and shows True or False.
    OnOff Converts to Boolean and shows Off for False, On for True.
    GeneralDate General date/time pattern (short time).
    LongDate Displays a date according to specified CultureInfo's long date format.
    MediumDate Displays a date using the medium date format ("dd-MMM-yy").
    ShortDate Displays a date using specified CultureInfo's short date format.
    LongTime Displays a time using your locale's long time format; includes hours, minutes, seconds.
    MediumTime Displays time in 12-hour format using hours and minutes and the AM/PM designator ("hh:mm tt").
    ShortTime Displays a time using the 24-hour format, for example, 17:45.
    LongDateShortTime Displays the long date and short time according to specified CultureInfo's format.
    LongDateLongTime Displays the long date and long time according to specified CultureInfo's format.
    ShortDateShortTime Displays the short date and short time according to specified CultureInfo's format.
    ShortDateLongTime Displays the short date and long time according to specified CultureInfo's format.
    MonthAndDay Displays the month and the day of a date.
    DateAndTimeGMT Formats the date and time as Greenwich Mean Time (GMT).
    DateTimeSortable Formats the date and time as a sortable index.
    GMTSortable Formats the date and time as a GMT sortable index.
    LongDateTimeGMT Formats the date and time with the long date and long time as GMT.
    YearAndMonth Formats the date as the year and month.