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

Change color or border a one header column

5 Answers 752 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Esteban
Top achievements
Rank 1
Iron
Iron
Esteban asked on 12 Jul 2018, 02:21 PM

I'm trying to highlight just one column header.
I would also like the whole column to have a different border to the others.
But I have not managed to modify any element of the header either.
This is the code I am using:

Private Sub RadGridView1_CellFormatting(sender As Object, e As UI.CellFormattingEventArgs) Handles RadGridView1.CellFormatting
 
        If TypeOf e.CellElement Is GridHeaderCellElement Then
            e.CellElement.Font = myCustomFont
            e.CellElement.BorderBoxStyle = BorderBoxStyle.OuterInnerBorders
 
        End If
End Sub

 

Thanks!

5 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 13 Jul 2018, 09:24 AM
Hi Esteban, 

For non-data cells, you need to use the ViewCellFormatting event, an example is available here: Formatting Cells.

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Esteban
Top achievements
Rank 1
Iron
Iron
answered on 15 Jul 2018, 05:51 AM

Thank you!

ViewCellFormatting is a correct event.

Not CellFormatting event.

;-)

0
Esteban
Top achievements
Rank 1
Iron
Iron
answered on 25 Jul 2018, 07:14 AM

Hello again!

I have managed to put the letter in bold and I have been able to change the style of the border. But I have not managed to change other properties of the header such as text or backcolor. Any suggestions?

Private Sub RadGridView1_CellFormatting(sender As Object, e As UI.CellFormattingEventArgs) Handles RadGridView1.ViewCellFormatting
 
       If TypeOf e.CellElement Is GridHeaderCellElement Then
 
           If e.CellElement.Text.Last = "*" Then
               e.CellElement.Text = "change text"                          '### NO
               e.CellElement.Font = myCustomFont                           '### YES
               e.CellElement.GradientStyle = GradientStyles.Solid          '### NO
               e.CellElement.BorderGradientStyle = GradientStyles.Solid    '### NO
               e.CellElement.BackColor = Color.Red                         '### NO
               e.CellElement.BorderColor = Color.Black                     '### NO
               e.CellElement.BorderBoxStyle = BorderBoxStyle.OuterInnerBorders '### YES
 
           Else
               e.CellElement.ResetValue(LightVisualElement.FontProperty, ValueResetFlags.Local)
               e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local)
 
           End If
 
       End If
 
 
   End Sub
0
Esteban
Top achievements
Rank 1
Iron
Iron
answered on 26 Jul 2018, 05:54 AM
Solved. I was misusing the methods.
0
Dimitar
Telerik team
answered on 26 Jul 2018, 12:46 PM
Hi Esteban,

I am glad that you have found a solution for this case. Do not hesitate to contact us if you have other questions.
 
Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
Esteban
Top achievements
Rank 1
Iron
Iron
Answers by
Dimitar
Telerik team
Esteban
Top achievements
Rank 1
Iron
Iron
Share this question
or