Methods | This Package | All Packages
Represents a data format object for formatting numeric data types.
DataFormat
|
+--NumberDataFormat
package com.ms.wfc.data
public class NumberDataFormat
extends DataFormat
implements IConstructable
Remarks
The Column and DataBinding classes provide a dataFormat property, which allows you to format numerical, date, or boolean values. For example, if a column in a DataGrid control has a numeric data type, you can set its dataFormat property to a NumberDataFormat object:
import com.ms.wfc.data.*;
import com.ms.wfc.data.ui.*;
/* Retrieve a numeric-valued column in a DataGrid control.
Assume this column has an index of 1 in the grid. */
Column column1 = dataGrid1.getColumn(1);
/* Format the column by setting its dataFormat
property. Create a NumberDataFormat object and
specify an initial numerical format string. */
column1.setDataFormat(new NumberDataFormat("#,##0"));
The NumberDataFormat class provides a format property that specifies a format string for numerical values. The following example shows how to set this property to change the initial format of the column:
/* Retrieve the column's current DateDataFormat object. */
NumberDataFormat nFormat = (NumberDataFormat) column1.getDataFormat();
/* Set the NumberDataFormat object's format
property to a different format string. */
nFormat.setFormat("#.000");
For information about formatting numerical values in the Forms Designer, see Formatting Data.
See Also BooleanDataFormat, DateDataFormat