I format grid cells based on a value, like a cell in column 1 greater than 90 would be green, but then I have to clear all the formatting and I use this code
{
}
my problem is that on grid with a good amount of rows and columns it takes the apps memory usage out of control and never releases it, is there any better alternative to clearing the formatting of a grid?
you were right, I had to loop through, thank you for all the help and for answering so fast
I don't think that it will overwrite the cell's appearances because the row maintains its own appearance that is used during the appearance resolution phase. You probably need to still loop through all the cells too (though if you find this to not be the case, by all means do what you're doing now :-))
-Matt
Great thanks for the quick response, I came up with this, will applying the appearance to the row overwrite the appearance I previously applied to the cell?
emptyAppearance.ForeColor = Color.Empty;
ugCurrentGrid.BeginUpdate();
ugCurrentGrid.EndUpdate();
I would look at the performance guide regarding using appearances. If you're setting the ForeColor/BackColor this way, then it's possible that you're also setting them in this way too, which means that you're creating a new Appearance object for every single cell in the grid, which would certainly increase the memory footprint. One option is to create a new Appearance object for each style that you need (i.e. a ForeColorGreenAppearance), and reuse that instance for all cells that need it. You could possibly call the ResetAppearance method to clear out any information on each cell to clear it them out instead of doing what you're doing as well, unless you have other appearances that you need to keep (in which case I would reuse those as well).