Formats and parses Double values.

Namespace: Dapfor.Net.Formats
Assembly: Dapfor.Net (in Dapfor.Net.dll) Version: 2.10.3.24917 (2.10.3.24917)

Syntax

C#
public sealed class DoubleFormat : IFormat
Visual Basic
Public NotInheritable Class DoubleFormat
	Implements IFormat
Visual C++
public ref class DoubleFormat sealed : IFormat
F#
[<SealedAttribute>]
type DoubleFormat =  
    class
        interface IFormat
    end

Remarks

A very important feature in .Net Grid is its ability to work directly with application business logic. Business logic is a set of classes that may have certain properties returning specific values, i.g. prices, quantities, dates, etc. Generally these values are represented by primitive types, such as System.Int32, System.Double, System.Decimal etc. To show this data in grid cells, it's sufficient to convert the necessary values into the System.String type by calling Object.ToString() or String.Format("{0}", value). However, this approach is not flexible and doesn't support parsing strings to objects. To fill in for this, the .Net Grid provides a very powerful system of formats to convert values into strings and vice-versa. These formats are fully customizable. For instance, the grid can display empty strings instead of "0" when a value equals 0 or add a separator between thousands or some prefix or suffix like "$". These formats can also parse strings back into values. For application programming it's better to have a set of format classes, where data presentation is centralized.

In programming, formats can be defined in the following places:

This format can be declared with the DoubleFormatAttribute. The following example demonstrates this:

 Copy imageCopy
public class Product
{
    private double price;

    //With this declaration all double values are formatted with DoubleFormat.
    [DoubleFormat(Precision = 3, ShortForm = true, ShowZero = false)]
    public double Price
    {
        get { return price; }
    }
}

//Populate the grid and set a specified format for the 'Price' column
public void PopulateGrid(Grid grid)
{
    //Initialize the grid
    grid.Headers.Add(new Header());
    grid.Headers[0].Add(new Column("Price"));

    //Another way to set up the format
    grid.Headers[0]["Price"].Format = new DoubleFormat(2, false, false);

    //Populate the grid
    grid.Rows.Add(new Product());
}

Inheritance Hierarchy

System..::..Object
  Dapfor.Net.Formats..::..DoubleFormat

See Also