Home Forums WinForms controls Xceed Grid for WinForms Formatting the currency fields for the grid Reply To: Formatting the currency fields for the grid

Xceed Support
Member
Post count: 5658

 

Hi Kozu,

The instance you are using is static. Hence, it is using the last value that you set it to.

 

Please use the following working sample as an example.

 

Example:

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Xceed.Grid.Editors;
using Xceed.Grid.Viewers;
using System.Globalization;

namespace _26323
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            Xceed.Grid.Licenser.LicenseKey = “”;
            InitializeComponent();
            Xceed.Grid.Column columnPrice = new Xceed.Grid.Column(“Price”, typeof(Double));
            this.grid.Columns.Clear();
            this.grid.Columns.Add(columnPrice);

            Xceed.Grid.DataRow row0 = this.grid.DataRows.AddNew();
            row0.Cells[“Price”].Value = 10.025;
            row0.EndEdit();
            Xceed.Grid.DataRow row1 = this.grid.DataRows.AddNew();
            row1.Cells[“Price”].Value = 5.55;
            row1.EndEdit();

            NumberFormatInfo nfi = new NumberFormatInfo();
            nfi.CurrencySymbol = “$”;
            grid.DataRows[0].Cells[“Price”].FormatProvider = nfi;
            grid.DataRows[0].Cells[“Price”].FormatSpecifier = “C”;

             NumberFormatInfo nfi1 = new NumberFormatInfo();
            nfi1.CurrencySymbol = “CAD”;
            grid.DataRows[1].Cells[“Price”].FormatProvider = nfi1;
            grid.DataRows[1].Cells[“Price”].FormatSpecifier = “C”;
        }
    }
}

Imported from legacy forums. Posted by Mohamed [Xceed] (had 1081 views)