Format font custom group

2 posts, 0 answers
  1. Lucas Aguiar
    Lucas Aguiar avatar
    1 posts
    Member since:
    Apr 2010

    Posted 02 Nov 2011 Link to this post

    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
  2. Ivan Petrov
    Ivan Petrov avatar
    705 posts

    Posted 07 Nov 2011 Link to this post

    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.

Back to Top