Cell Style ViewCellFormatting

3 posts, 0 answers
  1. Jorge
    Jorge avatar
    4 posts
    Member since:
    Jan 2016

    Posted 23 Mar Link to this post

    With this code I get the following (NOT_OK.png)

    01.Private Sub RadGridView1_ViewCellFormatting(sender As Object, e As CellFormattingEventArgs) Handles RadGridView1.ViewCellFormatting
    02.    If TypeOf e.CellElement Is GridHeaderCellElement Then
    03.        With e.CellElement
    04.            Dim myFont As New Font(New FontFamily("Calibri"), 10.0F, FontStyle.Bold)
    05. 
    06.            If InStr(.Text, "IN") > 0 Then
    07.                xColor = Color.FromArgb(150, 54, 52)
    08.            ElseIf InStr(.Text, "OUT") > 0 Then
    09.                xColor = Color.FromArgb(54, 96, 146)
    10.            ElseIf .Text = "Fecha" Then
    11.                xColor = Color.FromArgb(38, 38, 38)
    12.            End If
    13. 
    14.            .DrawBorder = True
    15.            .DrawFill = True
    16. 
    17.            .Font = myFont
    18.            .ForeColor = Color.White
    19.            .GradientStyle = GradientStyles.Solid
    20.            .BackColor = xColor
    21.        End With
    22.    Else
    23.        Dim xColor As Color = Color.Red
    24.        Dim xWidth As Integer = 5
    25.        With e.CellElement
    26.            '.DrawFill = True
    27.            '.NumberOfColors = 1
    28.            '.BorderBoxStyle = BorderBoxStyle.FourBorders
    29.            Select Case .ColumnIndex
    30.                Case 9 '0, 9, 16
    31.                    .BorderRightColor = xColor
    32.                    .BorderRightWidth = xWidth
    33.            End Select
    34.        End With
    35.    End If
    36.End Sub

     

    what I need is OK.png

     

    Thank you,

     

     

  2. Hristo
    Admin
    Hristo avatar
    716 posts

    Posted 23 Mar Link to this post

    Hello Jorge,

    Thank you for writing.

    In order to improve its performance and memory footprint, RadGridView is using UI virtualization, meaning that the visual elements are reused.

    In order to accomplish your task please reset the values of the defined styles. The following article provides additional information and examples: Formatting Cells.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Jorge
    Jorge avatar
    4 posts
    Member since:
    Jan 2016

    Posted 23 Mar Link to this post

    Thank you
Back to Top