This is a migrated thread and some comments may be shown as answers.

using ConditionalFormattingObject with combined conditions

1 Answer 147 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 1
Simon asked on 22 Dec 2011, 03:27 PM
Hi

I have 

 Dim cResolved As New ConditionalFormattingObject("Resolved", ConditionTypes.Equal, "Resolved", "", True)
    cResolved.RowForeColor = Color.DarkGreen
        cResolved.CellForeColor = Color.DarkGreen
        dgServices.Columns("Status").ConditionalFormattingObjectList.Add(cResolved)

And this works great. How would I add another condition to this so 

"Status = Resolved" AND ResolveUser="USER"

Thanks in advance

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 27 Dec 2011, 02:14 PM
Hello Simon,

Thank you for writing.

While the ConditionalFormattingObject is convenient way for formatting rows it can handle only one condition. If you want to apply more complex conditions, you should make use of the RowFormatting event of RadGridView. Here is an example for your case:
Private Sub RadGridView1_RowFormatting(sender As Object, e As Telerik.WinControls.UI.RowFormattingEventArgs) Handles RadGridView1.RowFormatting
       If e.RowElement IsNot Nothing Then
           If e.RowElement.Data.Cells(0).Value = "Resolved" And e.RowElement.Data.Cells(1).Value = "USER" Then
               e.RowElement.ForeColor = Color.DarkGreen
           Else
               e.RowElement.ResetValue(LightVisualElement.ForeColorProperty, Telerik.WinControls.ValueResetFlags.Local)
           End If
       End If
   End Sub

I hope that the provided information addresses your question. Should you have any other questions, do not hesitate to contact us.
 
All the best,
Stefan
the Telerik teamQ3’11 of RadControls for WinForms is available for download (see what's new). Get it today.
Tags
GridView
Asked by
Simon
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or