I have a grid that is bound to a collection of objects. There are cases where I need to change the foreground color of a specific cell in a row to red. I have this working except for when the row is selected. When a row is selected the text color for all of the cells in the entire row changes to white. When that happens the user cannot tell that the cell in question is red until he selects a different row. How can I keep the formatting of my cell even when the row is selected?
Thanks,
Matt
Hello ,
Appearance objects are applied based on the hierarchy, and selected and Active row appearance are with high priority. On this way end user always know which exactly row is selected and which is active. Ultimately customer know which rows he was selected. That is why and UltraGrid works on this way. However you could use IUIDrawFilter interface in order to control drawing process of UltraGrid components. I’ve implemented simple sample for you, it is with Infragistics 14.1 and the same approach also should works with Infragistics 8.2.
I hope that this will helps you.
There are easier ways than using a DrawFiler.
For one thing, you could set the ActiveAppearance and/or SelectedAppearance on the cell. By applying the same ForeColor to the SelectedAppearance as you did to the Appearance, the cell would maintain it's ForeColor, even when selected.
Another option would be to use the SelectionOverlay feature instead of the default solid-color selection. This way, the selection appears as a semi-transparent overlay on top of the existing colors, like in Excel.
Thank you both for your responses. I am using version 8.1 of Infragistics and I read that the SelectionOverlay feature wasn't introduced until version 9.2. Upgrading is not an option for this project. I've tried setting ActiveAppearance and SelectedAppearance of the cell but cells are not actually active or selected in my grid. I have tried manually marking the cell as selected in the AfterSelectChange event and setting the .SelectedAppearance to a predefined appearance that I have created. However when the row is selected the cell still looks the same and the text is still white.
Hi Matt,
What do you mean "cells are not actually active or selected in my grid?" The SelectedAppearance on the cell will apply, even if the cell itself is not selected, but the cell appears selected because the row or column are selected. So that should work okay. Unless you are not allowing selection at all and just simulating it in some way - in which case, you would not be having the problem of the forecolor changing when the row is selected. So that doesn't make sense to me.
The alternative solution, before we added SelectedAppearance on the cell and the SelectionOverlay stuff would be to use a DrawFilter. It's much more complex and difficult, but there's a discussion about this approach along with some sample code here:
DrawFilter for Backcolor - Infragistics Forums
Mike,
I got the DrawFilter working the way I need it to using the example you pointed me to. Thanks for you help.
I do allow row selection but not cell selection so that's what I meant. I didn't think the cells were actually selected even though a row is. Sorry for the confusion. Here is the code that I've tried in the grid's AfterSelectChange event and the selected row still has a fore color of white instead of dark red.
For Each row As Infragistics.Win.UltraWinGrid.UltraGridRow In grdActivities.Selected.Rows row.Cells("StartDateTime").SelectedAppearance.ForeColor = Color.DarkRed row.Cells("StartDateTime").SelectedAppearance.FontData.Bold = DefaultableBoolean.True row.Cells("StartDateTime").SelectedAppearance.FontData.SizeInPoints = 12.5 Next
The DrawFilter may work for me. But I need to know how to have it only apply to certain cells in a row and not every cell.