ComponentOne True DBGrid for .NET (2.0) Search HelpCentral 

C1DataColumn.NumberFormat Property

Gets or sets the formmating string for a column.

[Visual Basic]

Public Property NumberFormat As String

[C#]

public string NumberFormat {get;set;}

[Delphi]

public property NumberFormat: String read get_NumberFormat write set_NumberFormat;

Remarks

This property returns or sets a value indicating the format string for a grid column. By default, the NumberFormat property contains an empty string, and column data is unformatted.

For numeric data, the following predefined format names can be used:

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.

Fixed

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

Standard

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

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.

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.

For date and time data, the following predefined format names can be used:

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 according to 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).

For arbitrary data, the following predefined format names can be used:

Edit Mask

Use the column's EditMask property to format the data for display as well as editing.

FormatText Event

Fire the C1TrueDBGrid.FormatText event for the associated column. This option allows you to write your own formatting code for situations where intrinsic formatting is unavailable or does not suit your needs.

The NumberFormat property also accepts user-defined format strings. See the Microsoft documentation (Format function) for details.

If the NumberFormat property is set to an invalid string, cell data are displayed as #ERR#.

Example

The following code sets the NumberFormat property of the HireDate column to Medium Date:

·      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';

See Also

C1DataColumn Class | C1DataColumn Members | C1.Win.C1TrueDBGrid Namespace


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