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

Cell Style ViewCellFormatting

2 Answers 103 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jorge
Top achievements
Rank 1
Jorge asked on 23 Mar 2016, 02:34 PM

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 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 23 Mar 2016, 04:34 PM
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.
0
Jorge
Top achievements
Rank 1
answered on 23 Mar 2016, 05:04 PM
Thank you
Tags
GridView
Asked by
Jorge
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Jorge
Top achievements
Rank 1
Share this question
or