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
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.
-Matt
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