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
close icon

table-rows: different style

Hi,
I'm using Essential PDF (VB) and I have created a report from a SQL-Server-database, as you see in the attachment. There is no problem to change the value of the fields, but is it also possible to change their format.
For example I want all negativ values in red color.
I only see a chance, if I assign the fields to different cells and then set the special format.
Please tell me if there is an easier way.

Thanks Claudia




rekapjahr.zip

1 Reply

VK Vinoth Kumar K Syncfusion Team January 14, 2008 08:32 PM UTC

Hi Claudia,

I want all negaive values in red color:
>>>>>>>>>>>>>>>>>>>>>

One way you can change color of the negative value in PDFTableCell to Color.Red by using EndCellLayout Event. Here is a code snippet that shows this task.

void table_EndCellLayout(object sender, EndCellLayoutEventArgs args)
{
int iCellValue;
if (int.TryParse(args.Value, out iCellValue))
{
if (iCellValue < 0)
{

PdfGraphics g = args.Graphics;
System.Drawing.Image image = new Bitmap((int)args.Bounds.Width, (int)args.Bounds.Height);
Graphics gra = Graphics.FromImage(image);
gra.Clear(Color.White); // Set new color.
PdfImage image1 = new PdfBitmap(image);

//Clear backgroung of the cells with white color
g.DrawImage(image1, args.Bounds);

//Draw
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 8);
g.DrawString(args.Value, font, PdfBrushes.Red, args.Bounds.Location);
}

}
}

Regards,
Vinoth




Loader.
Live Chat Icon For mobile
Up arrow icon