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

Change font for one column in RadGridView on runtime (VB.net)

1 Answer 186 Views
GridView
This is a migrated thread and some comments may be shown as answers.
ISB-developer
Top achievements
Rank 2
ISB-developer asked on 02 Nov 2011, 10:32 AM
Hi
I need to change the font for one column of my RadGridView in runtime. Is this possible?
If Yes, can you help me with the code in VB.NET?
Thanks

1 Answer, 1 is accepted

Sort by
0
Ivan Petrov
Telerik team
answered on 03 Nov 2011, 03:59 PM
Hi Isb-Developer,

Thank you for writing.

You can use the CellFormatting event of the RadGridView. Consider the following code snippet which demonstrates this:

Private m_boldFont = New Font("Helvetica", 10, FontStyle.Bold)
 
Public Sub New()
  InitializeComponent()
  AddHandler Me.RadGridView1.CellFormatting, AddressOf RadGridView1_CellFormatting
End Sub
 
Private Sub RadGridView1_CellFormatting(ByVal sender As Object, ByVal e As CellFormattingEventArgs)
  If e.ColumnIndex = 1 Then
    e.CellElement.Font = Me.m_boldFont
  Else
    e.CellElement.ResetValue(LightVisualElement.FontProperty, ValueResetFlags.Local)
  End If
End Sub

Note that the creation of a Font is a heavy operation and can lead to memory leaks. It is best to create one font and use it across the application.

I hope this will help you. If you have further questions, I would be glad to help. Best wishes,
Ivan Petrov
the Telerik team

Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

Tags
GridView
Asked by
ISB-developer
Top achievements
Rank 2
Answers by
Ivan Petrov
Telerik team
Share this question
or