This project has moved. For the latest updates, please go here.
1

Closed

Help!! [changing the font color and size]

description

First of all very nice work.

How can I change the font and or the font size of a column or change the default font size, color.

How can I appear Percent completed column like in the photo of the article in code project?

Thanks in Advance.
Closed Sep 2, 2014 at 9:06 PM by VahidN

comments

VahidN wrote Feb 18, 2013 at 5:17 PM

Hello,
  • To change the default font size or color, just use the other methods of DefaultFonts builder:
.DefaultFonts(fonts =>
             {
                 fonts.Path(...);
                 fonts.Color(...);
                 fonts.Size(...);
             })
  • To see how change the default font or color of a cell or column, try CustomCellTemplate sample.
    It's possible to change these values by using the ConditionalFormatFormula:
template.ConditionalFormatFormula(list =>
                         {
                             var cellValue = int.Parse(list.GetSafeStringValueOf("Month", nullValue: "0"));
                             if (cellValue == 7)
                             {
                                 return new CellBasicProperties
                                 {
                                     PdfFontStyle = DocumentFontStyle.Bold | DocumentFontStyle.Underline,
                                     FontColor = new BaseColor(System.Drawing.Color.Brown),
                                     BackgroundColor = new BaseColor(System.Drawing.Color.Yellow)
                                 };
                             }
                             return new CellBasicProperties { PdfFontStyle = DocumentFontStyle.Normal };
                         });
or in the CellCreated event:
.MainTableEvents(events =>
             {
                 events.CellCreated(args =>
                     {
                         //change the background color of the cell based on the value
                         if (args.RowType == RowType.DataTableRow && args.Cell.RowData.Value != null && args.Cell.RowData.Value is decimal)
                         {
                             if ((decimal)args.Cell.RowData.Value <= 1000)
                                 args.Cell.BasicProperties.BackgroundColor = BaseColor.CYAN;
                         }
                     });
             })
  • You can find that sample with percent completed column here. In this sample, the default column template (template.TextBlock()) is changed to ProgressBar column template:
column.ColumnItemsTemplate(template =>
                    {
                        template.ProgressBar(progressBarColor: Color.SkyBlue, showPercentText: true);
                        template.DisplayFormatFormula(obj =>
                        {
                            if (obj == null) return "% 0";
                            return "% " + obj.ToString();
                        });
                    });

wrote Feb 18, 2013 at 5:18 PM

ntziortzios wrote Feb 19, 2013 at 6:29 AM

I appreciate you quick response.

Once again excellent work.

Thanks.

wrote Feb 21, 2013 at 10:56 PM

wrote Sep 2, 2014 at 9:06 PM