Forgive me if this question has already been answered. I'm populating a UltraWinGrid and two of the columns have dates. I'm attempting to conditionally format the cell's background color depending on date ages of "no date", 6months, 8 months, and 12 months, as compared to the current date. I think I should be using the ValueBasedAppearance, The Conditional Formatting dialog box, and the UltraCalcManager, but am not 100% sure if this is the correct approach. Can someone point me to examples of conditional cell formatting based on date values?
Thanks,
-Todd
Hi Todd,
ValueBasedAppearances are most useful at design-time where you can use the designer to set them up. It is therefore difficult for us to provide useful samples for them - because the functionality relies on the designer, not the code.
If you are setting up your appearances at design-time, your grid has to have a data source at design-time and the columns must already exist. If that's the case, then I'm sure there are tutorials in the documentation that would help you here.
But if you are trying to apply the appearances at run-time, it's much easier to use the InitializeRow event and apply an appearance to the cell yourself. There is sample code in the WinGrid Performance Guide which describes how to do this in the most efficient way.
Hi Mike,
I'm trying to apply conditional formatting in the InitializeRow event. The initial request for data formats the rows as I want but when the user invokes a new request and the data changes, the original formatting is still applying because the row is already initialized. Is there a way, to clear the formatting after each request so that the contents of the cell are re-evaluated and new formatting is applied. I tried to do this in the InitializeComponent with value based appearance but the columns do not exist at design time.
Private Sub ugZipCodeAdjReport_InitializeRow(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeRowEventArgs) Handles ugZipCodeAdjReport.InitializeRow
If Not (Me.Disposing Or Me.IsDisposed) Then
ugZipCodeAdjReport.BeginUpdate()
Try
If e.Row.Cells.Exists("Zip") Then
e.Row.Cells("Zip").Appearance.BackColor = Color.White
If e.Row.Cells("Zip").Value.ToString.EndsWith("*") Then
e.Row.Cells("Zip").Appearance.BackColor = Color.LightBlue
End If
End if
e.Row.Cells(
"Zip").Appearance.BackColor = Color.LightBlue
Your information was helpful. I ended up using RefreshRow.FireInitializeRow and that allowed me to get the desirable results I needed for formatting
Hi,
I'm not sure I'm following you. The IntiializeRow event fires both when the row is initially created and also any time any value in a cell of that row changes. So I'm not sure exactly what you mean by "the user invokes a new request and the data changes", but if this involves any change to any value in any cell of the row, the event will fire again. So this event is ideally suited to formatting a cell based on a value.