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

Format font custom group

1 Answer 120 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Lucas Aguiar
Top achievements
Rank 1
Lucas Aguiar asked on 03 Nov 2011, 12:17 AM
When I create a group like this:
             GroupDescriptor GroupDescriptor descriptor = new ("GrupoVencimento");
             descriptor.GroupNames [0]. ListSortDirection.Descending = Direction;
             descriptor.Aggregates.Add ("Sum (Value)");
             this.rgvContasReceberParcela.GroupDescriptors.Add (descriptor);

How do I format the font, size, style, etc.?

thank you

1 Answer, 1 is accepted

Sort by
0
Ivan Petrov
Telerik team
answered on 07 Nov 2011, 09:49 AM
Hi Lucas Aguiar,

Thank you for writing.

You can use the ViewCellFormatting event of the RadGridView to set the font for the group cells and for the data cells. Consider the following code snippet which demonstrates this:

private Font normalFont = new Font("Helvetica", 10);
private Font bigFont = new Font("Helvetica", 14);
 
private void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
  if (e.CellElement is GridGroupContentCellElement)
  {
    e.CellElement.Font = bigFont;
  }
  else if (e.CellElement is GridDataCellElement)
  {
    e.CellElement.Font = normalFont;
  }
}

Note that the creation of a font is a heavy operation and may easily lead to performance and memory issues, so it is a good idea to create fonts only once and then reuse them.

I hope this will help. Should you have further questions, I would be glad to help. Regards,
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
Lucas Aguiar
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Share this question
or