RadGridView - Change Header Column color WITHOUT event

1 Answer 126 Views
GridView
João
Top achievements
Rank 1
Iron
Iron
Iron
João asked on 07 Oct 2022, 11:32 AM

Hi there!

I'm programming in an old language so most of these events are a little buggy. Any formatting event throws by far the most bugs so I managed to go around them and make the programs work. However right now i need to change a column header color without using those events. I found in this site a way to change the cell color by using

THIS-OBJECT:gridCabecalhos:Rows[currentRowIndex]:Cells[currentColumnIndex]:Style:BackColor     = THIS-OBJECT:currentColor

Is there a way to do the same to the column headers?

 

JP

1 Answer, 1 is accepted

Sort by
1
Dess | Tech Support Engineer, Principal
Telerik team
answered on 10 Oct 2022, 05:17 AM

Hi, João,

Since RadGridView uses UI virtualization, its cell elements are created for the currently visible cells and they are being reused during operations like scrolling. That is why the ViewCellFormatting and ViewRowFormatting events are appropriate for customizing the header cells' style. The following forum post is quite useful on this topic:

https://www.telerik.com/forums/custom-style-in-some-columns#2410238 

Please have in mind that the Style property will have effect only for the data cells, not the header cells: https://docs.telerik.com/devtools/winforms/controls/gridview/cells/formating-examples/style-property 

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

Regards,
Dess | Tech Support Engineer, Principal
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.

João
Top achievements
Rank 1
Iron
Iron
Iron
commented on 10 Oct 2022, 10:00 AM

Hi Dess! Thank your for the reply!

I understand those events are exacly for this situation but I'm in a special situation where i won't be able to use them. Are you sure there isn't any way to workaround this?

JP

Dess | Tech Support Engineer, Principal
Telerik team
commented on 11 Oct 2022, 11:33 AM

João, Currently, the possible solution to style the header cells is to use the ViewCellFormatting event:

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

However, I have logged it in our feedback portal by creating a public thread on your behalf. You can track its progress, subscribe for status changes and add your comments on the following link - feedback item.

I have also updated your Telerik points.

  
João
Top achievements
Rank 1
Iron
Iron
Iron
commented on 11 Oct 2022, 11:45 AM

Hey Dess!

Thank you for that and for the attention.  Have a nice one!

JP

Tags
GridView
Asked by
João
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or