We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to change to BOLD the font of the Group row in the CustomPrintManagerBase

How to change to bold the font of the Group Row in the printing options.? I used CustomPrintManagerBase and OnRenderCell overloading.

protected override void OnRenderCell(DrawingContext drawingContext, RowInfo rowInfo, CellInfo cellInfo)

{

var index = dataGrid.View.Records.IndexOfRecord(rowInfo.Record);


var rect = new Rect((cellInfo.CellRect).X, (cellInfo.CellRect).Y + 0.5, (cellInfo.CellRect).Width, (cellInfo.CellRect).Height);


if (index % 2 == 0)

drawingContext.DrawGeometry(new SolidColorBrush(Color.FromRgb(245, 245, 245)), new Pen(), new RectangleGeometry(rect));


//Colors.Bisque


if (index == -1 &&

rowInfo.Record is Group)

{

//Convet text to BOLD?????????? HOW?????

}


base.OnRenderCell(drawingContext, rowInfo, cellInfo);

}


1 Reply

BR Balamurugan Rajaraman Syncfusion Team August 16, 2017 07:13 AM UTC

Hi Deigo, 
 
Thanks for contacting Syncfusion support. 
 
We have checked your query “How to customize the summary row”. You can able to achieve your requirement by overriding the OnDrawText method of the GridPrintManager class as like the below provided code sample 
 
protected override void OnDrawText(DrawingContext drawingContext, RowInfo rowInfo, CellInfo cellInfo, string cellValue) 
{ 
    double thickness = 0; 
    var contentrect = AddBorderMargins(cellInfo.CellRect, new Thickness(5, Math.Ceiling(thickness / 2), 5, Math.Ceiling(thickness / 2))); 
    FormattedText formattedText = GetFormattedText(rowInfo, cellInfo, cellValue); 
    var textalignment = TextAlignment.Left; 
    var textwrap = TextWrapping.NoWrap; 
    if (rowInfo.RowType == RowType.HeaderRow || rowInfo.RowType == RowType.StackedHeaderRow) 
    { 
        textalignment = TextAlignment.Center; 
        textwrap = TextWrapping.Wrap; 
    } 
    else if(cellInfo.ColumnName != "" && (rowInfo.Record is Group)) 
    { 
        //-->here sets the Font weight as Bold for the Summary Row 
        formattedText.SetFontWeight(FontWeights.Bold); 
    } 
    else if (cellInfo.ColumnName != "" && !(rowInfo.Record is Group)) 
    { 
        textalignment = GetColumnTextAlignment(cellInfo.ColumnName); 
        textwrap = GetColumnTextWrapping(cellInfo.ColumnName); 
        //-->Here we have applied the Foreground color for the record row 
        var index = dataGrid.View.Records.IndexOfRecord(rowInfo.Record); 
        if (index % 2 == 0) 
            formattedText.SetForegroundBrush(Brushes.Bisque); 
    } 
 
    if (contentrect.Width > 0 && contentrect.Height > 0) 
    { 
 
        formattedText.MaxTextWidth = contentrect.Width; 
        formattedText.MaxTextHeight = contentrect.Height; 
        formattedText.TextAlignment = textalignment; 
        if (textwrap != TextWrapping.NoWrap) 
            formattedText.Trimming = TextTrimming.None; 
        else 
        { 
            formattedText.Trimming = TextTrimming.CharacterEllipsis; 
            formattedText.MaxLineCount = 1; 
        } 
 
        drawingContext.DrawText(formattedText, contentrect.TopLeft); 
    } 
} 
 
In this sample we have applied the Font weight as Bold for the summary row and at the same we have applied the font color to the default row as per the requirement. We have attached that sample for your reference you can able to get it from the below link 
 
 
Regards, 
Balamurugan R 


Loader.
Live Chat Icon For mobile
Up arrow icon