why is the grid coloring wrong cells when i group the data? it works until you do a group by.
Imports System.ComponentModel
Imports Telerik.WinControls
Imports Telerik.WinControls.UI
Public Class Form1
Private _list As New BindingList(Of data)
Private _groups() As String = {"one", "two", "three", "four"}
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
GenData()
grid.DataSource = _list
End Sub
Private Sub GenData()
For i = 0 To 1000
_list.Add(New data() With {.Foo = "foo" + i.ToString,
.Bar = _groups(i Mod 4),
.Bye = "bye" + i.ToString,
.Hi = "hi" + i.ToString,
.Index = i})
Next
End Sub
Private Sub grid_CellFormatting(sender As Object, e As CellFormattingEventArgs) Handles grid.CellFormatting
If TypeOf e.Row Is GridViewDataRowInfo Then
If e.CellElement.ColumnInfo.Name.ToLower = "foo" Then
Dim b As data = CType(e.Row.DataBoundItem, data)
If b.Index Mod 2 > 0 Then
e.CellElement.DrawFill = True
e.CellElement.BackColor = Color.Pink
Console.WriteLine(e.CellElement.ColumnInfo.Name + " going pink - " + e.CellElement.RowIndex.ToString)
e.CellElement.GradientStyle = GradientStyles.Linear
Else
e.CellElement.DrawFill = False
e.CellElement.BackColor = Color.White
Console.WriteLine(e.CellElement.ColumnInfo.Name + " going white - " + e.CellElement.RowIndex.ToString)
e.CellElement.GradientStyle = GradientStyles.Solid
End If
End If
End If
End Sub
End Class
Public Class data
Public Property Foo As String = ""
Public Property Bar As String = ""
Public Property Hi As String = ""
Public Property Bye As String = ""
Public Property Index As Integer = -1
End Class