I have succesfully used ValueBasedAppearance to conditionally change the colors in cells. The problem is that when the row where this cell lives is activated, the Appearance takes over and I lose the formatting. This goes back to normal as soon as another row is selected but my users are requesting that at least the ForeColor of those cells stays the same.
Does anybody know how to achieve this? I am using 2007.1
Thanks!
Sebastian
HOWTO:How can I have Selected cells in a grid maintain their forecolor?
DrawFilter for Backcolor - Infragistics Forums
Mike,
I'm almost there. The problem is that the KB code I got overrides with the cell appearance, but that appearance doesn't take into account the ValueBasedAppearance applied. I tried to use "Resolve Appearance" to get to the actual ForeColor being used but there are two properties
(ByVal dataValue As Object, _ ByVal context As IConditionContextProvider)
that I don't know how to fill. I looked in the forms and in the help but can't find anything useful.
Any help is greatyl appreciated.
The context is generally only used in a FormulaCondition, so if you have that you could pass in the instance of the column as the IConditionContextProvider, I believe.
-Matt
That did it! Thanks!
I think that your best bet in this case is to do what I mentioned in a previous post and created your own class that derives from IConditionContextProvider for each cell and use that in the call to ResolveAppearance. For the Context property you should return the specific cell that is associated with that column.
Private Class CellContextProvider Implements Infragistics.Win.IConditionContextProvider Dim cell As UltraGridCell Public Sub New(ByRef cell As UltraGridCell) Me.cell = cell End Sub Public ReadOnly Property Context() As Object Implements Infragistics.Win.IConditionContextProvider.Context Get Return Me.cell End Get End Property End Class
Hopefully this fixes it for you.
That's right. I have three Formula conditions attached to each cell in a specific Rows. All these conditions refer to other fields' values to determine whether they should paint themselves red/green (or stay black).
The conditions work great but I get white foreground on every highlighted cell whether the conditions match true or not.
Hope this helps.
It is hard to say just based on this code what the problem could be. Are you saying that regardless of what the cell value is, the appData.ForeColor is white? Could you attach a small sample to your post, or perhaps paste the condition that you're using as well, and perhaps what data should match it?
I do that,and then all fonts are white... Here's the Code for my DrawFilter.
'Dim a variabl to hold the cell Dim aCell As UltraGridCell Dim aRow As UltraGridRow Select Case drawPhase Case drawPhase.BeforeDrawForeground aRow = drawParams.Element.SelectableItem
If aRow.Selected Then If (Not aRow.Band.Columns(0).ValueBasedAppearance Is Nothing) Then Dim appData As AppearanceData Dim requestedProps As AppearancePropFlags Dim clsconditionValueAppearance As ConditionValueAppearance appData = New AppearanceData() requestedProps = AppearancePropFlags.AllRender clsconditionValueAppearance = aRow.Band.Columns(0).ValueBasedAppearance 'It's always the first column
clsconditionValueAppearance.ResolveAppearance(appData, requestedProps, aRow.Cells(0).Value, nothing)
drawParams.AppearanceData.ForeColor = appData.ForeColor End If End If End Select