Cell Color in DataGrid

Nov 2, 2009 at 11:25 AM
Edited Nov 2, 2009 at 11:34 AM

Hi!

i use this code to color cells dependent on there values

 

            SourceGrid.Cells.Views.Cell blackView = new SourceGrid.Cells.Views.Cell();
            blackView.ForeColor = Color.Black;

            SourceGrid.Cells.Views.Cell yellowView = new SourceGrid.Cells.Views.Cell();
            yellowView.BackColor = Color.Yellow;

            SourceGrid.Cells.Views.Cell greenView = new SourceGrid.Cells.Views.Cell();
            greenView.BackColor = Color.Green;

            SourceGrid.Cells.Views.Cell redView = new SourceGrid.Cells.Views.Cell();
            redView.BackColor = Color.Red;

            SourceGrid.Cells.Views.Cell blueView = new SourceGrid.Cells.Views.Cell();
            blueView.BackColor = Color.Blue;


            for (int i = 1; i <= tagesplanPforte.Rows.Count; i++)
            {
                SourceGrid.Cells.ICellVirtual cell = gridTagesplanPforte.GetCell(i, 11);

                if (tagesplanPforte.Rows[i - 1].ItemArray[11].ToString() == "nicht eingetroffen")
                {
                    cell.View = blackView;
                }
                else if (tagesplanPforte.Rows[i - 1].ItemArray[11].ToString() == "auf Standspur")
                {
                    cell.View = yellowView;
                }
                else if (tagesplanPforte.Rows[i - 1].ItemArray[11].ToString() == "im Werk")
                {
                    cell.View = greenView;
                }
            }

 

 

my problem is that not only one cell is colored, but the complete column.....what can i do?

Nov 3, 2009 at 9:18 AM

Here is an example what i want to do

 

http://freak1988.fr.ohost.de/grid.jpg

Dec 11, 2009 at 12:06 AM

Try running step by step, have an error i think.