Microsoft SDK for Java

NumberDataFormat Class

The NumberDataFormat class of the com.ms.wfc.data package represents a data format object for formatting numeric data types.

public class NumberDataFormat extends DataFormat implements IConstructable 
{
  // Constructors
  public NumberDataFormat(String format);

  // Methods
  public String getFormat();
  public void setFormat(String value);
}

Remarks

The Column and DataBinding classes provide a dataFormat field, 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");

See Also

BooleanDataFormat
DateDataFormat

© 1999 Microsoft Corporation. All rights reserved. Terms of use.