How can I control the background colour of the extended bit of the header in a RadVirtualGrid?

1 Answer 33 Views
VirtualGrid
Jason
Top achievements
Rank 1
Jason asked on 27 Jan 2025, 11:56 AM

Hi,

How can I control the background colour of the extended bit of the header in a RadVirtualGrid? See the area circled in red on the screenshot.

Thanks in advance,

__Jason

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 30 Jan 2025, 07:00 AM

Hello Jason,

There is no mechanism that allows you to change only the marked part of the header border. You can only change the background of the entire border with the ColumnHeaderBackground property of RadVirtualGrid.

<telerik:RadVirtualGrid ColumnHeaderBackground="Green" />

An extra idea that you can explore is to fix the column's widths with the ColumnWidth property of RadVirtualGrid and calculate a gradient brush for the ColumnHeaderBackground. For example:

<telerik:RadVirtualGrid x:Name="virtualGrid"
                        ColumnWidth="120"
                        InitialRowCount="10" 
                        InitialColumnCount="3" 
                        SizeChanged="virtualGrid_SizeChanged"/>

 

 private void virtualGrid_SizeChanged(object sender, SizeChangedEventArgs e)
 {            
     double columnsLength = (virtualGrid.InitialColumnCount * virtualGrid.ColumnWidth);
     double offset = columnsLength / (virtualGrid.ActualWidth - virtualGrid.RowHeaderWidth);

     var brush = new LinearGradientBrush();
     brush.StartPoint = new Point(0, 0.5);
     brush.EndPoint = new Point(1, 0.5);            
     brush.GradientStops.Add(new GradientStop(Colors.Red, 0));
     brush.GradientStops.Add(new GradientStop(Colors.Red, offset));
     brush.GradientStops.Add(new GradientStop(Colors.Green, offset));

     virtualGrid.ColumnHeaderBackground = brush;            
 }

Regards,
Martin Ivanov
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.

Jason
Top achievements
Rank 1
commented on 30 Jan 2025, 09:22 AM

Hi Martin,

Thanks. I had eventually discovered that it was the ColumnHeaderBackground and I'd set that to transparent and was using the HeaderCellDecorationsNeeded event to colour the actual cells. I also need to do the same thing for pinned header rows. Unfortunately, I then hit the next problem which is that, in the version of the components we are using, there is a bug that means we don't get an event for CellDecorationsNeeded for pinned cells. So this will have to wait until we find the opportunity to upgrade. But thanks for making some suggestions.

__Jason

Tags
VirtualGrid
Asked by
Jason
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or