Completed
Last Updated: 13 Oct 2015 06:51 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 12 Jun 2015 07:01
Category: GridView
Type: Bug Report
0
FIX. RadGridView - CellFormatting event is not fired enough times to indicate correctly the cell/row state when the selection is changed
To reproduce:
Me.RadGridView1.MultiSelect = True

Private Sub RadGridView1_CellFormatting(sender As Object, e As Telerik.WinControls.UI.CellFormattingEventArgs) _
Handles RadGridView1.CellFormatting
    If e.Row.IsSelected Then
        e.CellElement.BackColor = Color.LimeGreen
        e.CellElement.DrawFill = True
        e.CellElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid
    Else
        e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local)
        e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local)
        e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local)
    End If
End Sub

Step 1: Select a few rows with the mouse click in combination with the CTRL key.
Step 2: The rows are selected correctly and the desired green back color is applied. Release the CTRL Key.
Step 3: Click with the mouse on a different row in the grid.

Result: All previously selected rows but the last current row keep the green back color.

Workaround:

Sub New()
    InitializeComponent()
 
    Me.RadGridView1.MultiSelect = True
    AddHandler Me.RadGridView1.SelectionChanging, AddressOf SelectionChanging
    AddHandler Me.RadGridView1.SelectionChanged, AddressOf SelectionChanged
 
End Sub
 
Private Sub RadGridView1_CellFormatting(sender As Object, e As Telerik.WinControls.UI.CellFormattingEventArgs) _
Handles RadGridView1.CellFormatting
    e.CellElement.DrawFill = True
    e.CellElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid
    If e.Row.IsSelected Then
        e.CellElement.BackColor = Color.LimeGreen
    Else
        e.CellElement.BackColor = Color.Yellow
    End If
End Sub
Private Sub SelectionChanged(sender As Object, e As EventArgs)
    For Each r As GridViewRowInfo In selectedRows
        r.InvalidateRow()
    Next
    selectedRows.Clear()
End Sub
 
Dim selectedRows As New List(Of GridViewRowInfo)
Private Sub SelectionChanging(sender As Object, e As GridViewSelectionCancelEventArgs)
    For Each r As GridViewRowInfo In Me.RadGridView1.SelectedRows
        selectedRows.Add(r)
    Next
End Sub
0 comments