You are welcome to .Net. the easiest way you can set format is by following the code below. Code: class Quote { ... [Format(typeof(CustomFormat))] public double Price { get { return _price; } } ... } CustomFormat : IFormat { private readonly string _formatString; public CustomFormat(string formatString) { _formatString = formatString; } public string Format(IDataField dataField) { return string.Format(CultureInfo.InvariantCulture, "{0:" + _formatString +"}", dataField.Value).Trim(); } public bool CanParse(string text, IDataField dataField) { return false; } public void Parse(string text, IDataField dataField) { } } //An attribure returning an instance of IFormat object public class CustomFormatAttribute : FormatBaseAttribute { private readonly string _formatString; public CustomFormatAttribute(string formatString) {
Hi, You can check this Code: class Quote { ... [Format(typeof(CustomFormat))] public double Price { get { return _price; } } ... } //Display a number using specific format string class CustomFormat : IFormat { private readonly string _formatString; public CustomFormat(string formatString) { _formatString = formatString; } public string Format(IDataField dataField) { return string.Format(CultureInfo.InvariantCulture, "{0:" + _formatString +"}", dataField.Value).Trim(); } public bool CanParse(string text, IDataField dataField) { return false; } public void Parse(string text, IDataField dataField) { } } //An attribure returning an instance of IFormat object public class CustomFormatAttribute : FormatBaseAttribute { private readonly string _formatString; public CustomFormatAttribute(string formatString) { _formatString = formatString; } public override IFormat Format { get { return new CustomFormat(_formatString); } } } //Declare custom format class Quote { ... [CustomFormat("### ### ##0.##")] public double Price { get { return _price; } } ... } Thanks