Data Format

To use data format, the following namespace is need to be imported.
using unvell.ReoGrid.DataFormat;
Specify cell data format by using SetRangeDataFormat method.
SetRangeDataFormat(ReoGridRange range, CellDataFormatFlag flag, object argument)
e.g.
grid.SetRangeDataFormat(ReoGridRange.EntireRange, CellDataFormatFlag.Number,
  new NumberDataFormatter.NumberFormatArgs()
  {
    // decimal digit places 0.1234
    DecimalPlaces = 4,
					
    // negative number style: (123) 
    NegativeStyle = NumberDataFormatter.NumberNegativeStyle.RedBrackets,
 
    // use separator: 123,456
    UseSeparator = true,
  });
Or using action:
RGSetRangeDataFormatAction(ReoGridRange range, CellDataFormatFlag format,
  object dataFormatArgs);
Test:
grid[1, 1] = 12345;
grid[1, 2] = 12345.67890;
grid[2, 1] = -1234;
grid[2, 2] = -1234.56789;

52.png

Built-in Data Formatter

Type CellDataFormatFlag Argument
Number CellDataFormatFlag.Number NumberDataFormatter.NumberFormatArgs
DateTime CellDataFormatFlag.DateTime DateTimeDataFormatter.DateTimeFormatArgs
Percent CellDataFormatFlag.Percent PercentDataFormatter.PercentFormatArgs
Currency CellDataFormatFlag.Currency CurrencyDataFormatter.CurrencyFormatArgs
Text CellDataFormatFlag.Text None

Samples

Number

47.png
Set cell to format data as number:
grid.SetRangeDataFormat(ReoGridRange.EntireRange, CellDataFormatFlag.Number,
  new NumberDataFormatter.NumberFormatArgs()
  {
    // decimal digit places 0.1234
    DecimalPlaces = 4,

    // use separator: 123,456
    UseSeparator = true,
  });

DateTime

48.png
grid.SetRangeDataFormat(ReoGridRange.EntireRange, CellDataFormatFlag.DateTime,
  new DateTimeDataFormatter.DateTimeFormatArgs
  {
    // culture
    CultureName = "en-US",

    // pattern
    Format = "yyyy/MM/dd",
  });

Percent

49.png
grid.SetRangeDataFormat(ReoGridRange.EntireRange, CellDataFormatFlag.Percent,
  new PercentDataFormatter.PercentFormatArgs
  {
    // decimal digit places
    DecimalPlaces = 2,
  });

Curreny

50.png
grid.SetRangeDataFormat(ReoGridRange.EntireRange, CellDataFormatFlag.Currency,
  new CurrencyDataFormatter.CurrencyFormatArgs
  {
    // culture name
    CultureEnglishName = "en-US",

    // decimal digit places
    DecimalPlaces = 1,

    // symbol
    Symbol = "$",
  });

Text

51.png
grid.SetRangeDataFormat(ReoGridRange.EntireRange, CellDataFormatFlag.Text, null);

Next: Group & Outline

Last edited May 28, 2014 at 6:47 AM by unvell, version 8