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

Is there any way to use a different PdfBrush per Column?

Hi,

What I'm trying to do is use a different background color each column in a PdfLightTable. The BeginRowLayout event has a CellStyle.BackgroundBrush property in the event args that I can use to color each row differently, but the BeginCellLayout doesn't have a CellStyle property. I can't seem to figure out how to color a cell independently of a row. Am I missing something? This seems like it should be possible.

Thanks,
Ken


3 Replies

BP Bhuvaneswari P Syncfusion Team February 12, 2009 02:19 PM UTC

Hi Ken,

Thank you for your interest in Syncfusion products.

I am working on this issue and will provide the details by tomorrow.

Best Regards,
Bhuvana



BP Bhuvaneswari P Syncfusion Team February 13, 2009 11:42 AM UTC

Hi Ken,

We don't have direct option to set different background color each column in a PdfLightTable. But we can work around this by using the BeginCellLayout event. In this event we have cell RowIndex and CellIndex properties based on this we can format the column. Please refers to the below code snippet tod
C#
static int r = 0,i=10;
void table_BeginCellLayout(object sender, BeginCellLayoutEventArgs args)
{
if ((args.CellIndex) != r)
{
r = 0; i = 10;
}
if (r % 2 != 0)
{
PdfBrush brush = PdfBrushes.Magenta;
args.Graphics.DrawRectangle(brush, args.Bounds);
}
else
{
PdfBrush brush = PdfBrushes.Green;
args.Graphics.DrawRectangle(brush, args.Bounds);
}
r++; i = i + 20;
}

Please refers to the below sample to do so:
'>http://websamples.syncfusion.com//samples/Pdf.Windows/F79491/main.htm">
http://websamples.syncfusion.com//samples/Pdf.Windows/F79491/main.htm

You can change the sample as per your requirement. Please let me know if this helps you.

Best Regards,
Bhuvana




KN Ken Nelson February 13, 2009 01:57 PM UTC

Ah I see, just overlap the cell background with a rectangle of whatver color I want. Yes that helps. Thanks!

Ken


Loader.
Live Chat Icon For mobile
Up arrow icon