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

SummaryRowGroupHeaders Propertys

3 Answers 32 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Veda
Top achievements
Rank 1
Veda asked on 22 Jan 2013, 07:48 AM
How to set font styles with colors while grouping Grid View Rows??

3 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 23 Jan 2013, 08:42 AM
Hi Veda,

Thank you for writing.

You can customize the group header appearance by handling the ViewCellFormatting event. You should modify GridGroupContentCellElement properties in this case:
void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
    GridGroupContentCellElement contentCell = e.CellElement as GridGroupContentCellElement;
    if (contentCell != null)
    {
        if (font == null)
        {
            font = new Font("Comic Sans MS", 12, FontStyle.Regular);
        }
        contentCell.Font = font;
        contentCell.ForeColor = Color.Red;
    }
}

You may also want to change how specific text parts look. The easiest way to do this is by handling GroupSummaryEvaluate event and use our html like syntax:
void radGridView1_GroupSummaryEvaluate(object sender, GroupSummaryEvaluationEventArgs e)
{
    if (e.Context is GridViewGroupRowInfo)
    {
        e.FormatString = "<html><b>{0}:</b><font='Courier MS'><color=green><i>{1}</i>";
    }
}

To enable this feature on you should set the DisableHTMLRendering property to false when handling ViewCellFormatting event:
void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
    GridGroupContentCellElement contentCell = e.CellElement as GridGroupContentCellElement;
    if (contentCell != null)
    {
        contentCell.DisableHTMLRendering = false;
    }
}

I hope this helps.
 
All the best,
Jack
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
Roger
Top achievements
Rank 1
answered on 23 Mar 2013, 06:18 PM

Hi coders

to get the font to display correctly I had to remove the single quotes. My font name was a single word, eg Arial. Not sure what would happen if there was a space in the font name - as in the example. Maybe then the single quotes would be necessary. Here's the corrected, working (for me) code

 "<html><b>{0}:</b><font=Arial><color=green><i>{1}</i>";

I hope this helps someone.

Useful code as I needed it to change the group font at {1}


Roger


0
Jack
Telerik team
answered on 27 Mar 2013, 03:00 PM
Hi Roger,

Yes, your solution is correct. Presently there is an issue when the font name is surrounded with single quotes. I logged the issue in our issue tracking system and we will address it in one of our upcoming releases. Use this link to track the issue status. I updated your Telerik points for this report. 
 
Greetings,
Jack
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
Tags
GridView
Asked by
Veda
Top achievements
Rank 1
Answers by
Jack
Telerik team
Roger
Top achievements
Rank 1
Share this question
or