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

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • User (Old forums)
    Post count: 23064
    #17402 |


    I’m trying to format the currency fields for my grid. The tricky part is that each row has a different currency. The first row should be in USD, and the second in CAD.

    I tried something like this:

    NumberFormatInfo nfi = System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat;
    nfi.CurrencySymbol = “$”;
    myGrid.DataRows[0].Cells[“Price”].FormatProvider = nfi;

    nfi = System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat;
    nfi.CurrencySymbol = “CAD”;
    myGrid.DataRows[1].Cells[“Price”].FormatProvider = nfi;

    The problem is that now both rows show CAD.

    What am I missing?



    Imported from legacy forums. Posted by kozu (had 1615 views)

    Xceed Support
    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.




    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 = “”;
                Xceed.Grid.Column columnPrice = new Xceed.Grid.Column(“Price”, typeof(Double));

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

                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)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.