using ConditionalFormattingObject with combined conditions

2 posts, 0 answers
  1. Simon
    Simon avatar
    7 posts
    Member since:
    Sep 2011

    Posted 22 Dec 2011 Link to this post

    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
  2. Stefan
    Admin
    Stefan avatar
    2908 posts

    Posted 27 Dec 2011 Link to this post

    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.
Back to Top