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.
In this case, the cell colors should be applying properly. I created a small sample using code similar to yours. Please take a look and let me know whether it works for you.
One additional change that I made was to disable selected and active appearances, as these will take precedence over cell.Appearance whether you are using a style or not.
ultraGrid1.DisplayLayout.Override.SelectedAppearancesEnabled = Infragistics.Win.DefaultableBoolean.False;ultraGrid1.DisplayLayout.Override.ActiveAppearancesEnabled = Infragistics.Win.DefaultableBoolean.False;
You can always tweak these appearances using cell.ActiveAppearance and cell.SelectedAppearance if you prefer not to disable them.
Hey Mike,
I am thankful for your help. But the issue still persists, no theme comprehends the fact that an appearance is applied on the cell.
BTW you provided a solution with a normal grid I am not facing any such issues with the normal grid. I am talking about the issue in a CARDVIEW grid. Please provide some insight if the handling in cardview is different.
Regards
Ishan Gandhi
I am currently working with the development team to verify the intended behavior of the appearance properties while in cardview. I will keep you up to date on my findings.
Appearance properties set on a cell should override appearance properties set by a style. The behavior you are seeing is not expected, and I haven't been able to reproduce it. What version of our toolkit are you using? Are you able to send a reproduction sample? I have integrated the code you provided into a sample, but was unable to reproduce it. I did change the grid to cardview in my sample, but the appearances worked as expected.
Hi,
The problem in this sample is that you only have one row in the grid, so that row is the ActiveRow, always. Your ISL file is applying an appearance to the ActiveRow (or ActiveCell). The Active state appearance is more specific than the cell, so it override the cell.Appearance.
This is easily fixed in one of two ways:
1) Remove the ActiveRow/ActiveCell Appearance from your isl.
2) When you set the Appearance on the Cell, also set the ActiveAppearance on the cell to the same appearance.
Oh... you might also want to set the SelectedAppearance on the cell, too.
Hello Mike,I am attaching source code, please check and suggest where we are missing.