public enum RowEnum : int
    {
        J = 0,
        JMoins1 = 1,
        SensDuMarchéBB = 2,
        SoldeDesAnticipésNominatif = 3,
        NominaCompta = 4,
        NominaManuel = 5,
        GlobalCompta = 6,
        GlobalManuel = 7,
        Devise = 8,
        PositionEnKDevises7Bis = 9,
        PositionManuelleEnKDevises8 = 10,
        Separator = 11,
        PrixMoyenManuel9 = 12,
        SpotReutersDuMoment = 13,
        ContreDevise = 14,
        ContrevaleurPositionManuelle12 = 15,
        GainsPertesPotentiels13 = 16,
        GainsPertesRealises = 17,
        StopLoss = 18
    }

    public class DataRowNew
    {
        public double J;
        public double JMoins1;
        public string SensDuMarchéBB;
        public double SoldeDesAnticipésNominatif;
        public double NominaCompta;
        public double NominaManuel;
        public double GlobalCompta;
        public double GlobalManuel;
        public string Devise;
        public double PositionEnKDevises7Bis;
        public double PositionManuelleEnKDevises8;
        public double PrixMoyenManuel9;
        public double SpotReutersDuMoment;
        public string ContreDevise;
        public double ContrevaleurPositionManuelle12;
        public double GainsPertesPotentiels13;
        public double GainsPertesRealises;
        public string StopLoss;
    }

        public void Load(string fileName, DataGridView dataGridView)
        {
            //
            // On lit le fichier XML et cela va créer une liste de DataRowNew
            //
            List<DataRowNew> dataRows = new List<DataRowNew>();
            XmlSerializer xmls = new XmlSerializer(typeof(List<DataRowNew>));
            StreamReader sr = new StreamReader(fileName);
            dataRows = (List<DataRowNew>)xmls.Deserialize(sr);
            sr.Close();

            int rows = dataRows.Count-1;
            dataGridView.Rows.Clear();
            dataGridView.Rows.Add(rows);

            int count = 0;
            foreach (DataRowNew row in dataRows)
            {
                //
                // Ajustement de la hauteur d'une ligne
                //
                DataGridViewRow r = dataGridView.Rows[count];
                r.Height = 15;

                dataGridView.Rows[count].Cells[0].Value = row.J;
                dataGridView.Rows[count].Cells[1].Value = row.JMoins1;
                dataGridView.Rows[count].Cells[2].Value = row.SensDuMarchéBB;
                dataGridView.Rows[count].Cells[3].Value = row.SoldeDesAnticipésNominatif;
                dataGridView.Rows[count].Cells[4].Value = row.NominaCompta;
                dataGridView.Rows[count].Cells[5].Value = row.NominaManuel;
                dataGridView.Rows[count].Cells[6].Value = row.GlobalCompta;
                dataGridView.Rows[count].Cells[7].Value = row.GlobalManuel;
                dataGridView.Rows[count].Cells[8].Value = row.Devise;
                dataGridView.Rows[count].Cells[9].Value = row.PositionEnKDevises7Bis;
                dataGridView.Rows[count].Cells[10].Value = row.PositionManuelleEnKDevises8;
                //dataGridView.Rows[count].Cells[11].Value = nothing because it is a separator;
                dataGridView.Rows[count].Cells[12].Value = row.PrixMoyenManuel9;
                dataGridView.Rows[count].Cells[13].Value = row.SpotReutersDuMoment;
                dataGridView.Rows[count].Cells[14].Value = row.ContreDevise;
                dataGridView.Rows[count].Cells[15].Value = row.ContrevaleurPositionManuelle12;
                dataGridView.Rows[count].Cells[16].Value = row.GainsPertesPotentiels13;
                dataGridView.Rows[count].Cells[17].Value = row.GainsPertesRealises;
                dataGridView.Rows[count].Cells[18].Value = row.StopLoss;

                count++;
            }
        }

        public void Save(string fileName, DataGridView dataGridView)
        {
            List<DataRowNew> dataRows = new List<DataRowNew>();

            foreach (DataGridViewRow row in dataGridView.Rows)
            {
                int count = 0;
                DataRowNew dataRow = new DataRowNew();
                foreach (DataGridViewCell cell in row.Cells)
                {
                    switch (count)
                    {
                        case 0:
                            dataRow.J = GridHelper.GetDoubleValue(row, RowEnum.J);
                            break;
                        case 1:
                            dataRow.JMoins1 = GridHelper
.GetDoubleValue(row, RowEnum.JMoins1); 
                            break;
                        case 2:
                            dataRow.SensDuMarchéBB = GridHelper
.GetStringValue(row, RowEnum.SensDuMarchéBB);
                            break;
                        case 3:
                            dataRow.SoldeDesAnticipésNominatif = GridHelper
.GetDoubleValue(row, 
RowEnum.SoldeDesAnticipésNominatif); 
                            break;
                        	
// 
// …
//

                        case 17:
                            dataRow.GainsPertesRealises = GridHelper
.GetDoubleValue(row, RowEnum.GainsPertesRealises); 
                            break;
                        case 18:
                            dataRow.StopLoss = GridHelper
.GetStringValue(row, RowEnum.StopLoss);
                            break;
                    }

                    count++;
                }
                dataRows.Add(dataRow);
            }

            //
            // Data is saved in DataRows -> XML
            //
            XmlSerializer xmls = new XmlSerializer(typeof(List<DataRowNew>));
            StreamWriter sw = new StreamWriter(fileName);
            xmls.Serialize(sw, dataRows);
            sw.Close();
        }

<?xml version="1.0" encoding="utf-8"?>
<ArrayOfDataRowNew xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <DataRowNew>
    <J>0</J>
    <JMoins1>0</JMoins1>
    <SensDuMarchéBB>A</SensDuMarchéBB>
    <SoldeDesAnticipésNominatif>0</SoldeDesAnticipésNominatif>
    <NominaCompta>-1</NominaCompta>
    <NominaManuel>0</NominaManuel>
    <GlobalCompta>400</GlobalCompta>
    <GlobalManuel>30</GlobalManuel>
    <Devise>AUD</Devise>
    <PositionEnKDevises7Bis>0</PositionEnKDevises7Bis>
    <PositionManuelleEnKDevises8>30</PositionManuelleEnKDevises8>
    <PrixMoyenManuel9>1070</PrixMoyenManuel9>
    <SpotReutersDuMoment>1.3615175676859721</SpotReutersDuMoment>
    <ContreDevise>USD</ContreDevise>
    <ContrevaleurPositionManuelle12>-40.845527030579163</ContrevaleurPositionManuelle12>
    <GainsPertesPotentiels13>32059.154472969421</GainsPertesPotentiels13>
    <GainsPertesRealises>30</GainsPertesRealises>
    <StopLoss />
  </DataRowNew>
  <DataRowNew>
…

        public static void LoadNominaCompta()
        {
            DB.NominaComptaCollection.Clear();

            string cnx = Settings.GetConnectionString();
            SqlDataReader dr = SqlHelper.ExecuteReader(cnx, CommandType.Text, 
"SELECT CODE_DEVISE, POSITION FROM NOMINA_COMPTA");
            while (dr.Read())
            {
                string devise = Convert.ToString(dr["CODE_DEVISE"]);
                double position = Convert.ToDouble(dr["POSITION"]);

                NominaCompta nc = new NominaCompta();
                nc.Devise = devise;
                nc.Position = position;
                DB.NominaComptaCollection.Add(nc);
            }
            dr.Close();
        }

        public static void CallReutersWS()
        {
            lock (Svc.LockReuters)
            {
                Svc.ReutersDataCollection.Clear();

                foreach (KeyValuePair<string, ReutersData> kvp 
in ReutersDataCollectionPrepared)
                {
                    try
                    {
                        //
                        // Call the SVC
                        //
                        FluxFinanciersServiceReference.FluxFinanciersClient ffc 
= new FluxFinanciersServiceReference.FluxFinanciersClient();
                        ffc.Open();

                        string devise = kvp.Key;
                        ReutersData rd = kvp.Value;
                        FluxFinanciersServiceReference.ResponseStatutCours statusCours 
= ffc.GetCoursDeChange(                                                                                   rd.Devise,                                                                                       rd.ContreDevise);

                        if (rd.SensDuMarche == "A")
                        {
                            rd.Bid = statusCours.Value.Bid.Value;
                        }

                        if (rd.SensDuMarche == "V")
                        {
                            rd.Ask = statusCours.Value.Ask.Value;
                        }

                        ffc.Close();

                        //
                        // Store the data
                        //

                        ReutersDataCollection.Add(devise, rd);
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }

        public void PrepareReutersData(DataGridView dataGridView)
        {
            lock (Svc.LockReuters)
            {
                Svc.ReutersDataCollectionPrepared.Clear();

                int count = 0;
                foreach (DataGridViewRow row in dataGridView.Rows)
                {
                    object objectDeviseInGrid = dataGridView
.Rows[count]
.Cells[Convert.ToInt32(RowEnum.Devise)].Value;
                    string deviseInGrid = Convert.ToString(objectDeviseInGrid);
                    object objectContreDeviseInGrid = dataGridView
.Rows[count]
.Cells[Convert.ToInt32(RowEnum.ContreDevise)].Value;
                    string contreDeviseInGrid 
= Convert.ToString(objectContreDeviseInGrid);
                    object objectSensDuMarche 
= dataGridView
.Rows[count]
.Cells[Convert.ToInt32(RowEnum.SensDuMarchéBB)].Value;
                    string sensDuMarche = Convert.ToString(objectSensDuMarche);

                    if (deviseInGrid == String.Empty)
                    {
                        break;
                    }

                    //
                    // Store Data
                    //
                    ReutersData rd = new ReutersData();
                    rd.SensDuMarche = sensDuMarche;
                    rd.Devise = deviseInGrid;
                    rd.ContreDevise = contreDeviseInGrid;
                    rd.Ask = 0;
                    rd.Bid = 0;

                    Svc.ReutersDataCollectionPrepared.Add(deviseInGrid, rd);

                    count++;
                }
            }
        }

        public static void ThreadProc(object data)
        {
            while (true)
            {
                if (canCloseApp == true)
                {
                    // App is closing so we stop the thread !
                    break;
                }

                DB.LoadNominaCompta();
                DB.LoadGlobalCompta();
                DB.LoadSoldeAnticipesNominatif();
                DB.LoadNominaAnticipe();
                Svc.CallReutersWS();

                canDisplayData = true;

                Thread.Sleep(2000);
            }
        }

        public void EnableThread()
        {
            Thread thread = new Thread(MainFrame.ThreadProc);
            thread.Start(null);
        }

        public void EnableTimer()
        {
            _timer = new System.Windows.Forms.Timer();
            _timer.Interval = 2000;
            _timer.Tick += _timer_Tick;
            _timer.Start();
        }

        private void _timer_Tick(object sender, EventArgs e)
        {
            View view = new View();
            view.PrepareReutersData(dataGridView1);

            if (canDisplayData == true)
            {
                View view2 = new View();
                view2.DisplayNominaCompta(dataGridView1);
                view2.DisplayGlobalCompta(dataGridView1);
                view2.DisplaySoldeAnticipesNominatif(dataGridView1);
                view2.DisplayNominaAnticipe(dataGridView2);
                view2.DisplayReutersData(dataGridView1);

                // Reset the boolean
                canDisplayData = false;
            }
        }

        public void DisplayNominaCompta(DataGridView dataGridView)
        {
            int count = 0;
            foreach (NominaCompta nc in DB.NominaComptaCollection)
            {
                dataGridView.Rows[count]
                    .Cells[Convert.ToInt32(RowEnum.NominaCompta)]
                    .Value = nc.Position;

                dataGridView.Rows[count]
                    .Cells[Convert.ToInt32(RowEnum.Devise)]
                    .Value = nc.Devise;

                count++;
            }
        }

    public class Formulas
    {
        public static void Formula_PositionManuelleEnKDevises8(
DataGridView dataGridView, int col, int row)
        {
            if (col == Convert.ToInt32(RowEnum.NominaManuel)
                || col == Convert.ToInt32(RowEnum.GlobalManuel))
            {
                double nm = GridHelper.GetDoubleValue(dataGridView, row, 
                    RowEnum.NominaManuel);
                double gm = GridHelper.GetDoubleValue(dataGridView, row, 
                    RowEnum.GlobalManuel);

                double sum = nm + gm;
                GridHelper.SetDoubleValue(dataGridView, row, 
                    RowEnum.PositionManuelleEnKDevises8, sum);
            }
        }

        public void EnableCellChanged_DGV1(DataGridView dataGridView1)
        {
            dataGridView1.CellValueChanged += DataGridView1_CellValueChanged;
        }

        private void DataGridView1_CellValueChanged(
object sender, 
DataGridViewCellEventArgs e)
        {
            DataGridView dataGridView = (DataGridView)sender;
            int col = e.ColumnIndex;
            int row = e.RowIndex;
            object objValue = dataGridView.Rows[row].Cells[col].Value;
            string value = Convert.ToString(objValue);
            string str = String.Format("row={0} col={1} value={2}", row, col, value);

            Formulas.Formula_PositionEnKDevises7Bis(dataGridView, col, row);
            Formulas.Formula_PositionManuelleEnKDevises8(dataGridView, col, row);
            Formulas.Formula_ContrevaleurPositionManuelle12(dataGridView, col, row);
            Formulas.Formula_CalculGainsPertesPotentiels(dataGridView, col, row);

            //
            // After all of these formulas, Reapply Thèmes.
            //
            ApplyColorTheme_DGV1(dataGridView);
            ApplyColorThemeOnValues_DGV1(dataGridView);
        }

        public void ApplyColorThemeOnValues_DGV1(DataGridView dataGridView)
        {
            int rowCount = 10;

            for (int c = 0; c < rowCount; c++)
            {
                AddMinusSignOnRowCell(dataGridView, c, RowEnum.SoldeDesAnticipésNominatif);
                AddMinusSignOnRowCell(dataGridView, c, RowEnum.NominaCompta);
                AddMinusSignOnRowCell(dataGridView, c, RowEnum.NominaManuel);
                AddMinusSignOnRowCell(dataGridView, c, RowEnum.GlobalCompta);
                AddMinusSignOnRowCell(dataGridView, c, RowEnum.GlobalManuel);
                AddMinusSignOnRowCell(dataGridView, c, RowEnum.PositionEnKDevises7Bis);
                AddMinusSignOnRowCell(dataGridView, c, RowEnum.PositionManuelleEnKDevises8);
                AddMinusSignOnRowCell(dataGridView, c, RowEnum.PrixMoyenManuel9);
                AddMinusSignOnRowCell(dataGridView, c, RowEnum.ContrevaleurPositionManuelle12);
                AddMinusSignOnRowCell(dataGridView, c, RowEnum.GainsPertesPotentiels13);
                AddMinusSignOnRowCell(dataGridView, c, RowEnum.GainsPertesRealises);
                AddMinusSignOnRowCell(dataGridView, c, RowEnum.StopLoss);
            }
        }

        public void AddMinusSignOnRowCell(DataGridView dataGridView, 
int c, RowEnum enumValue)
        {
            DataGridViewCell cell;

            cell = dataGridView.Rows[c].Cells[Convert.ToInt32(enumValue)];
            Object value = cell.Value;
            string strValue = Convert.ToString(value);
            if (String.IsNullOrEmpty(strValue) == true)
            {
                return;
            }

            double dValue;
            if (Double.TryParse(strValue, out dValue) == false)
            {
                return;
            }

            double doubleValue = Convert.ToDouble(value);
            if (doubleValue < 0)
            {
                cell.Style.ForeColor = Color.Red;
            }
            else
            {
                cell.Style.ForeColor = Color.Black;
            }
        }