Declined
Last Updated: 06 Feb 2018 06:47 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 22 Feb 2017 09:25
Category: GridView
Type: Bug Report
0
FIX. RadGridView - cell's back color is not reset when you hover a cell and move the cursor to another cell
To reproduce: please refer to the attached gif file and sample project.

Workaround: when you set the DrawFill property to true, specify the BackColor to the desired one and reset for the rest of the cells.

private void radGridView1_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
{
    if (e.Column.Name == "ProductName" && e.Row is GridViewDataRowInfo)
    {
        if (e.CellElement.Value.ToString().Contains("C"))
        {
            e.CellElement.DrawFill = true;
            e.CellElement.BackColor = Color.Yellow;
            e.CellElement.GradientStyle = GradientStyles.Solid;
            e.CellElement.ForeColor = Color.OliveDrab;
        }
        else
        { 
            e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
            e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
            e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local);  
            e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);  
        }
    }
    else
    { 
        e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local);    
        e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);  
    }
}
1 comment
ADMIN
Ralitsa
Posted on: 06 Feb 2018 06:47
Each theme has its own specific theming mechanism for RadGridView. For example, the ControlDefault theme is designed to paint the fill of Current and Selected states in the row element (the fill of cells is not painted DrawFill = false). Hover state is painted in the cells and if we decide to set DrawFill of the cell to true in its normal state on CellFormatting, the BackColor will remain from its previous state (yellow for Hover). The theme is designed not to paint the fill on normal state and this is why the BackColor property is not set for this state.
Currently, we can suggest setting manually the BackColor of cells.