RadGridView - Telerik.WinControls.GridView(2015.1.331.40) e.CellElement.BackColor =Color.Red; not working

1 Answer 107 Views
GridView
Om Pushkara deep
Top achievements
Rank 2
Iron
Iron
Iron
Om Pushkara deep asked on 14 Jun 2021, 08:12 AM

Hi ,

I am using RadGridView - Telerik.WinControls.GridView(2015.1.331.40) and using CellFormating event . The backcolor doesnt work here whereas the forecolor works . Am i missing anything ?

The code attached:


   private void radGridView1_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
        {
            // e.CellElement.ForeColor works though
             e.CellElement.BackColor = Color.Red;
            
        }

1 Answer, 1 is accepted

Sort by
1
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 14 Jun 2021, 08:16 AM

Hi,

Specifying the BackColor property for the CellElement is not enough. It is necessary to ensure that the DrawFill property is enabled as well and the appropriate GradientStyle is applied (e.g. Solid). I would highly encourage you to have a look at the following help article demonstrating how to properly use the CellFormatting event in RadGridView:

https://docs.telerik.com/devtools/winforms/controls/gridview/cells/formatting-cells 

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Om Pushkara deep
Top achievements
Rank 2
Iron
Iron
Iron
commented on 14 Jun 2021, 09:01 AM

That worked pretty well. I set number of colours property and drawfill property to do the trick. That example doesn't mention how to use the gradient style property though . But just said that out of curiosity.
Dess | Tech Support Engineer, Principal
Telerik team
commented on 14 Jun 2021, 09:06 AM

Setting the NumberOfColors property to 1 means that only the BackColor property will be used. It is pretty similar to setting the GradientStyle to Solid.  Depending on the NumberOfColors value, BackColor, BackColor2, 3, 4, can be used for achieving  GradientStyles.Linear
Om Pushkara deep
Top achievements
Rank 2
Iron
Iron
Iron
commented on 14 Jun 2021, 09:22 AM

Wow. That answers it pretty well . Thanks once again.
Tags
GridView
Asked by
Om Pushkara deep
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or