Hello
I have a gridcardview which is a part of a major project. I am trying to set different forecolor to cells depending upon their value. I have tried to set the appearance of the cells by checking the value and it works fine without the theme. But as soon as the theme is applied the color changes to white.
I had earlier read a post in forum which said that individual appearance is not overridden by the stylist. I have another grid in the same layout in which the appearance of the whole row is being set depending on the value of one cell and in this case the appearance works fine.
Could you provide any solution to why this might be happening
Hi Ishan,
If you set the appearance on an individual row or cell with code like this:
ultraGrid1.Rows[1].Cells[0].Appearance.ForeColor = Color.Yellow;
then it should override AppStylist. How are you setting the appearances?
Hi Mike,
I have to change the cell color depending upon the content for every row. Here is the code I am using
private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e) { CellsCollection cells = e.Row.Cells;
foreach (UltraGridCell cell in cells)
{ if (cell.Column.DataType != typeof(System.Double)) { continue; } if (!cell.Column.Hidden) { ColorCell(cell); } } }
private void ColorCell(UltraGridCell cell) { if (cell.Value == null) { return; } string s = cell.Value.ToString(); if (s == string.Empty) { return; } double value = double.Parse(s); if (value > 0) { cell.Appearance.ForeColor = Color.FromArgb(177, 216, 64); } else if (value < 0) { cell.Appearance.ForeColor = Color.FromArgb(255, 91, 71); } else { //in case of zero cell.Appearance.ForeColor = Color.White; }
}
Please explain the reason for such a situation.