ComponentOne True DBInput Pro 8.0
DisplayFormat Property (TDBDate)

The DisplayFormat property sets/returns the display format used in the control. The format is specified by creating a mask using keywords and literals. If this property is set to a zero-length string, the Format property setting will be used for the display format.

Syntax

TDBDate.DisplayFormat= string

Read/Write at run time and design time.

Values

The following are the keywords available in the DisplayFormat property (yyyy/mm/dd is the default):

y

Display the year as a number without a leading zero (0 - 99).

yy

Display the year as a 2-digit number (00 - 99).

yyy

Display the year as a number without a leading zero (100 - 9999).

yyyy

Display the year as a 4-digit number (0100 - 9999).

m

Display the month as a number without a leading zero (1 - 12).

mm

Display the month as a number with a leading zero (01 - 12).

mmm

Display the month as an abbreviation (Jan - Dec).

mmmm

Display the month as a full month name (January - December).

MMM

Display the month as an abbreviation in upper case (JAN - DEC).

MMMM

Display the month as a full month name in upper case (JANUARY - DECEMBER).

d

Display the day as a number without a leading zero (1 - 31).

dd

Display the day as a number with a leading zero (01 - 31).

ddd

Display the day as an abbreviation (Sun - Sat).

dddd

Display the day as a full name (Sunday - Saturday).

DDD

Display the day as an abbreviation in upper case (SUN - SAT).

DDDD

Display the day as a full name in upper case (SUNDAY - SATURDAY).

aaa

Display the first character of the (DBCS) day-youbi. (NICHI - DO ).

aaaa

Display the full (DBCS) day-youbi. (NICHI-YOUBI - DO-YOUBI ).

g

Display the era name in alphabet (M, T, S, H).

gg

Display the first character (DBCS) era.

ggg

Display the full (DBCS) era.

e

Display the nengo year as a single digit number when possible.

ee

Display the nengo year as a 2 digit number.

{}

Specify a zero-length string or a SBCS character between the braces which fills the character in all the digits of the display mask for Null and era format patterns.

;

Delimiter between different format patterns.

Remarks

When keywords need to be used as literals, place a backslash before the keyword. This will differentiate a keyword from a literal.

You can use this property to separate the display format from the input format, making it possible to display dates in complex format with easier input. For example, to display Mar 29 '97, and yet have the user key only 032997, set DisplayFormat property to mmm/dd/'yy and the Format property to mm/dd/yy. Combining the use of DisplayFormat property with the Format property reduces keystrokes.

The DisplayFormat property allows you to determine three separate format patterns, delimited with a semicolon (";"). The first pattern is used to define the display mask, the second for Null values and the third for values that cannot be expressed in era format. For example:

TDBDate.DisplayFormat = _

    "yyyy/mm/dd ddd;Empty;Can't be expressed in Era format"

You can also simplify the Null and the Era format patterns by using braces ("{}") to specify a SBCS character to fill in all digits based on the display mask. For example, string expressions such as "9999/99/99 999" can be set as:

TDBDate.DisplayFormat = "yyyy/mm/dd ddd;{9};{9}"

The era expression can be used in the following situation:

TDBDate.DisplayFormat = "ggg ee/mm/dd;;{9}"

TDBDate.Value = "1500/01/01"

With the example above, the control will display a string, "9999/99/99" by filling 9 in all the digits specified in the display format, since 1500/01/01 can not be expressed in the Era format. Once you start inputting, the display mask will be applied.

If a zero-length string is set between the braces such as "yyyy/mm/dd;{};{}", the control will display blank when setting the value to Null or Era.

When more than one character is defined within the braces, the control picks the first character in the expression for implementing.

Note that the keywords except the braces ("{}") will be treated as literal characters within the Null and the Era patterns. If the braces are needed, place a backslash before them to differentiate from a literal.

If the Null expression and the era expression are omitted, the control uses the display format which includes all the literals and the prompt character specified in the PromptChar property (default is "_") to express Null and era (same as when clearing the control).

When DisplayFormat and Format are both set to a zero-length string, the value set by code and the date selected from the Calendar will be displayed, using the system short date.

For example:

' Setup the entry format

TDBDate.Format = ""

TDBDate.DisplayFormat = ""

TDBDate.Value = "03/16/98"

In the case above, the control can not determine in what format to display the current underlying value. Therefore, the system short date will be applied and the control will display "1998/03/16".

The following example shows the relation between the DisplayFormat and the Format property.

If the DisplayFormat property is set to a zero-length string, the format string set to the Format property will be used both for inputting and displaying.

TDBDate.Format = "yyyy.mm.dd;Null;Era"

TDBDate.DisplayFormat = ""

If the mask section of the DisplayFormat property is omitted, only the input mask defined in the Format property will be inherited. Note that the Null and the Era patterns will not be overridden.

TDBDate.Format = "yyyy.mm.dd"

TDBDate.DisplayFormat = ";Null;Era"

TDBDate.Format = ""

TDBDate.DisplayFormat = ";Null;Era"

The following example will be treated the same as when setting both the Format and the DisplayFormat properties to a zero-length string. This is because the control can not determine which input mask to base on for filling in a SBCS character in all the specified digits.

TDBDate.Format = ""

TDBDate.DisplayFormat = ";{9};{9}"

If the mask section of both the Format and the DisplayFormat property are defined, the input mask and the display mask will work independent, without inheriting or influencing each other.

TDBDate.Format = "yyyy.mm.dd;Null;Era"

TDBDate.DisplayFormat = "dd.mm.yyy"

The character specified between the braces ("{}") in the format must be set to a zero-length string or a SBCS character. A DBCS character will be treated as an error.

The display format is recommended to use the four digit years "yyyy" instead of two. This is to avoid the year 2000 (Y2K) compliant problems.

See Also

Value Property (TDBDate)

Text Property (TDBDate)

DisplayText Property (TDBDate)

Format Property (TDBDate)

MinDate Property (TDBDate)

MaxDate Property (TDBDate)

PromptChar Property (TDBDate)

InvalidInput Event (TDBDate)

InvalidValue Event (TDBDate)

InvalidRange Event (TDBDate)

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback