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

RowFormatting event for change text color.

2 Answers 56 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Peter Bogoyavlensky
Top achievements
Rank 1
Peter Bogoyavlensky asked on 16 Jun 2014, 02:12 PM
I've used RowFormatting event to change text color (in order of checking condition based on Tag of the row):

Private Sub GridView_RowFormatting(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.RowFormattingEventArgs) Handles GridView.RowFormatting
    Dim dataRow As Telerik.WinControls.UI.GridRowElement = e.RowElement
    If dataRow IsNot Nothing Then
        Try
            If dataRow.RowInfo.Tag IsNot Nothing Then
                If Is_Check_Some_Condition(dataRow.RowInfo.Tag) Then
                    dataRow.ResetValue(Telerik.WinControls.UI.LightVisualElement.ForeColorProperty, Telerik.WinControls.ValueResetFlags.Local)
                Else
                    dataRow.ForeColor = Color.Blue
                End If
            End If
        Catch ex As Exception
        End Try
    End If
End Sub

It works fine if version 2013.2.724. But when I changed it to 2014.1.402 - it is not working anymore. I mean, event is fired and dataRow.ForeColor = Color.Blue executed but text color is not changed.

Did I miss something for new version?

2 Answers, 1 is accepted

Sort by
0
Peter Bogoyavlensky
Top achievements
Rank 1
answered on 16 Jun 2014, 02:20 PM
Sorry, my bad - I've just noticed that similar issue raised in that thread : http://www.telerik.com/forums/rowformatting-and-office2010blue-theme

I also use Office2010Blue theme and this is the source of problem.

Can I fix it for 2014.1.402 ? It would be so boring to change this nice theme to another one through all application.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 19 Jun 2014, 08:45 AM
Hello Peter,

Thank you for writing.

In Office2010Blue theme there is a specific black ForeColor applied for the GridDataCellElements. That is why it is more suitable to use the CellFormatting event instead of the RowFormatting event:
Private Sub RG_Orders_CellFormatting(sender As Object, e As CellFormattingEventArgs)
    If IsDBNull(e.CellElement.RowElement.RowInfo.Cells("IDTeams").Value) Then
        e.CellElement.RowElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local)
    Else
        Select Case Trim(e.CellElement.RowElement.RowInfo.Cells("IDTeams").Value)
            Case "A"
                e.CellElement.ForeColor = Color.DarkBlue
            Case "B"
                e.CellElement.ForeColor = Color.DarkRed
            Case "C"
                e.CellElement.ForeColor = Color.DarkGreen
            Case Else
                e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local)
        End Select
    End If
End Sub

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GridView
Asked by
Peter Bogoyavlensky
Top achievements
Rank 1
Answers by
Peter Bogoyavlensky
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or