Assembly: Dapfor.Net (in Dapfor.Net.dll) Version: 2.10.3.24917 (2.10.3.24917)
Syntax
C# |
---|
public sealed class DecimalFormatAttribute : FormatBaseAttribute |
Visual Basic |
---|
Public NotInheritable Class DecimalFormatAttribute Inherits FormatBaseAttribute |
Visual C++ |
---|
public ref class DecimalFormatAttribute sealed : public FormatBaseAttribute |
F# |
---|
[<SealedAttribute>] type DecimalFormatAttribute = class inherit FormatBaseAttribute 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:
- As an attribute of a class property. For example: FormatAttribute, DecimalFormatAttribute, EmptyFormatAttribute, etc.
- In a column: Column.Format = 'your format';
- Directly in a cell (this method requires a lot of memory): Cell.Format = 'your format';
The DecimalFormat can be declared with the DecimalFormatAttribute. The following example demonstrates this:
Copy | |
---|---|
public class Product { private decimal price; [DecimalFormat(Precision = 3, ShortForm = true, ShowZero = false)] public decimal 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")); //Populate the grid grid.Rows.Add(new Product()); } |
Inheritance Hierarchy
System..::..Attribute
Dapfor.Net.Formats..::..FormatBaseAttribute
Dapfor.Net.Formats..::..DecimalFormatAttribute