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

ConditionalFormattingObject is not working on Null Cells

2 Answers 302 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 26 Feb 2010, 02:26 PM
I want to be able to highlight all rows that have a null value in a certain column. However when i try to use the following object its not working on null values.

Im calling this on the load of my form, or should i be calling this on the rowformatting event?

Private

 

Sub SetConditions()

 

 

Dim obj As New ConditionalFormattingObject("MyCondition", ConditionTypes.Equal, System.DBNull.Value.ToString, "", True)

 

obj.CellForeColor = Color.Red

obj.RowBackColor = Color.Yellow

 

Me.RadGridView_SessionData.Columns("Assignment").ConditionalFormattingObjectList.Add(obj)

 

 

End Sub

Any ideas!

 

2 Answers, 1 is accepted

Sort by
0
Michael
Top achievements
Rank 1
answered on 26 Feb 2010, 07:56 PM
Can anyone assist me with this question!
0
Martin Vasilev
Telerik team
answered on 03 Mar 2010, 03:40 PM
Hello Michael,

Thank you for writing. Actually, ConditionalFormatting functionality in RadGridView does not support applying conditions based on null or empty string values. However, you can still implement such functionality through the CellFormatting event:
Private Sub radGridView1_CellFormatting(ByVal sender As Object, ByVal e As CellFormattingEventArgs)
    If e.CellElement.ColumnIndex = 6 Then
        If DirectCast(e.CellElement, GridDataCellElement).Value.ToString().Equals([String].Empty) Then
            e.CellElement.DrawFill = True
            e.CellElement.BackColor = Color.Red
            e.CellElement.GradientStyle = GradientStyles.Solid
        Else
            e.CellElement.ResetValue(GridDataCellElement.DrawFillProperty, ValueResetFlags.Style)
            e.CellElement.ResetValue(GridDataCellElement.BackColorProperty, ValueResetFlags.Style)
            e.CellElement.ResetValue(GridDataCellElement.GradientStyleProperty, ValueResetFlags.Style)
        End If
    End If
End Sub

Let me know if you have any other questions.

Best wishes,
Martin Vasilev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Michael
Top achievements
Rank 1
Answers by
Michael
Top achievements
Rank 1
Martin Vasilev
Telerik team
Share this question
or