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

Problem with pinned column and CellFormatting event

2 Answers 80 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 08 Jul 2011, 03:27 PM
In my RadGridView, I've marked one column as pinned.  Without any formatting, this column shows up as a sky blue color.  When I apply some cell formatting in the RadGridView's CellFormatting event, the cells in the pinned column are white.  I presume this is because I'm resetting cell element formatting values for cells that don't meet the formatting criteria.  When I mouse over any cells in the RadGridView, it causes the cells in the pinned column to turn blue again.  I've thought about adding a check for IsPinned in the CellFormatting event and changing the color to blue myself, but it seems that this should be handled by the ResetValue method.  But, before I submit a bug report, I wanted to make sure I shouldn't be doing something differently.

Thanks,
Robert

Private Sub RadGridView1_CellFormatting(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles RadGridView1.CellFormatting
 
   Dim equationFont As New Font("Cambria", 9, FontStyle.Bold Or FontStyle.Italic)
 
   If e.Row.DataBoundItem.Row("EQUATION") = "Y" Then
            e.CellElement.Font = equationFont
            If gbUseColorCoding Then ' global boolean variable for users to disable colors
                e.CellElement.DrawFill = True
                e.CellElement.NumberOfColors = 1
                e.CellElement.BackColor = Color.PaleGoldenrod
            Else
                e.CellElement.ResetValue(LightVisualElement.DrawFillProperty)
                e.CellElement.ResetValue(LightVisualElement.NumberOfColorsProperty)
                e.CellElement.ResetValue(LightVisualElement.BackColorProperty)
            End If
        Else
            e.CellElement.ResetValue(LightVisualElement.FontProperty)
            e.CellElement.ResetValue(LightVisualElement.DrawFillProperty)
            e.CellElement.ResetValue(LightVisualElement.NumberOfColorsProperty)
            e.CellElement.ResetValue(LightVisualElement.BackColorProperty)
        End If
End Sub

2 Answers, 1 is accepted

Sort by
0
Accepted
Svett
Telerik team
answered on 12 Jul 2011, 12:52 PM
Hi Robert,

When you are resetting the property values, you should clear only their local repositories. You should do that in this way:

private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
    Font equationFont = new Font("Cambria", 9, FontStyle.Bold | FontStyle.Italic);
    bool gbUseColorCoding = true;
 
    string value = Convert.ToString(e.Row.Cells["CustomerID"].Value);
    if (value.StartsWith("A"))
    {
        e.CellElement.Font = equationFont;
        // global boolean variable for users to disable colors
        if (gbUseColorCoding)
        {
            e.CellElement.DrawFill = true;
            e.CellElement.NumberOfColors = 1;
            e.CellElement.BackColor = Color.PaleGoldenrod;
        }
        else
        {
            e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
            e.CellElement.ResetValue(LightVisualElement.NumberOfColorsProperty, ValueResetFlags.Local);
            e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
        }
    }
    else
    {
        e.CellElement.ResetValue(LightVisualElement.FontProperty, ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.NumberOfColorsProperty, ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
    }
}

I hope this helps.

Regards,
Svett
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Robert
Top achievements
Rank 1
answered on 12 Jul 2011, 12:57 PM
Great, exactly what I needed to know!  Thanks!
Tags
GridView
Asked by
Robert
Top achievements
Rank 1
Answers by
Svett
Telerik team
Robert
Top achievements
Rank 1
Share this question
or