ComponentOne True DBGrid for .NET (2.0) Search HelpCentral 

Numeric Field Formatting

True DBGrid supports a variety of data formatting options through the C1DataColumn object's NumberFormat property.  The NumberFormat property reconfigures the data format that is handed to the grid from the database. It can alter most types of numeric values for a particular column.  For example, to display all date values within a column according to the form 26-Apr-01, use the Medium Date setting:

·      Visual Basic

Me.C1TrueDBGrid1.Columns("HireDate").NumberFormat = "Medium Date"

·      C#

this.c1TrueDBGrid1.Columns("HireDate").NumberFormat = "Medium Date";

·      Delphi

Self.C1TrueDBGrid1.Columns['HireDate'].NumberFormat := 'Medium Date';

Note that if the NumberFormat property of a column is changed at run time, the display does not need to refresh since True DBGrid handles this automatically.

For numeric data, the following predefined options are available:

Standard

Display number with thousands separator, at least one digit to the left and two digits to the right of the decimal separator.

General Number

Display number as is, with no thousand separators.

Currency

Display number with thousand separator, if appropriate; display two digits to the right of the decimal separator. Note that output is based on system locale settings.

Percent

Display number multiplied by 100 with a percent sign (%) appended to the right; always display two digits to the right of the decimal separator.

Fixed

Display at least one digit to the left and two digits to the right of the decimal separator.

Scientific

Use standard scientific notation.

Yes/No

Display No if number is 0; otherwise, display Yes.

True/False

Display False if number is 0; otherwise, display True.

On/Off

Display Off if number is 0; otherwise, display On.

0%

Display number multiplied by 100, rounded to the nearest integer, with a percent sign (%) appended to the right.

0.00%

Same as Percent.

For date and time data, the following predefined options are available:

General Date

Display a date and/or time. For real numbers, display a date and time (for example, 4/3/93 05:34 PM); if there is no fractional part, display only a date (for example, 4/3/93); if there is no integer part, display only a time (for example, 05:34 PM). Date display is determined by your system settings.

Long Date

Display a date using your system's long date format.

Medium Date

Display a date using the medium date format appropriate for the language version of Visual Basic.

Short Date

Display a date using your system's short date format.

Long Time

Display a time using your system's long time format: includes hours, minutes, and seconds.

Medium Time

Display a time in 12-hour format using hours and minutes and the AM/PM designator.

Short Time

Display a time using the 24-hour format (for example, 17:45).


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.