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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:

Created:

Updated:

Platform:

Replies:

132125 Aug 15,2017 04:17 PM UTC Aug 16,2017 07:13 AM UTC WPF 1
loading
Tags: SfDataGrid
Diego Fernando Urabayen
Asked On August 15, 2017 04:17 PM UTC

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);

}


Balamurugan Rajaraman [Syncfusion]
Replied On 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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;