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 column format

Hi,

I am creating a pdf containing several tables that are drawn using datas contained in dataTables.
For each dataTable, I have a list of column indexes (for eg 1,3 and 6) corresponding to columns I would like to highlight using a different format(for eg a different brush color) as they are breakdowns of the column they come after, how can I do that?
Or is there a way to change the styles of the columns that have a certain code in there header?

Thanks ,
Clo


7 Replies

GM Geetha M Syncfusion Team October 11, 2011 11:42 AM UTC

Hi Clo,

Thank you for your interest in Syncfusion products.

Yes, it is possible to apply formatting to cell / row /column level. If you are using PdfLightTable, you can make use of BeginCellLayout event or PdfCellStyle. Please check the following documentation for more details:

BeginCellLayout event

Cell Style

If you are working with PdfGrid, you can apply format in the PdfGridCell. Here is the documentation link:
Cell Content Formating

Please try this and let me know if you have any questions.

Regards,
Geetha



CV Chloe Vuillet October 13, 2011 09:44 AM UTC

I am having trouble implementing this.
If we use the class attached:
I have a "TableTest" struct that contains
- a dataTable
- a list of int
I created an element toto with a DataTable that contains 3 columns and just added 2 to the list of int => I created three cell styles :
- the default
- the alternate
- the "breakdownStyle" => one I want to use for the columns whose indexes belong to the list of int (eg 2 here).

How can I do that? I tried using the BeginCellLayout event but couldnt manage it.

Thanks and regards
Clo



Test_6879ec52.zip


GM Geetha M Syncfusion Team October 17, 2011 10:27 AM UTC

Hi Clo,

Thank you for the details.

You can make use of the following code snippet to achieve the expected behavior:

table.BeginCellLayout += new BeginCellLayoutEventHandler(table_BeginCellLayout);

void table_BeginCellLayout(object sender, BeginCellLayoutEventArgs args)
{
if (args.CellIndex == 1)
{
string text = args.Value;
args.Graphics.DrawString(text, breakdownStyle.Font, breakdownStyle.BackgroundBrush, args.Bounds);
args.Graphics.DrawRectangle(breakdownStyle.BorderPen, args.Bounds);
args.Skip = true;
}
}

Please try this and let me know if you have any questions.

Regards,
Geetha



RG Raghav Gokakkar November 10, 2011 12:49 PM UTC

Hi,

I need to have different color and format for each cell depending on the value. When I tried above snippet (args.Skip = true), all lines of the table get written at the same location (overlap each other). Without Skip=true, it works but the text gets written twice in each cell. Can you please advice.



GM Geetha M Syncfusion Team November 11, 2011 09:52 AM UTC

Hi Raghav,

Thank you for your interest in Syncfusion products.

In order to achieve the desired behavior, could you please make use of PdfGrid instead of PdfLightTable. Instead of making use of events, you can format the cell before drawing PdfGrid. Please check our documentation in the following link for more details.

Cell Content Formatting

Please try this and let me know if you have any questions.

Regards,
Geetha



DY Dylan replied to Geetha M March 1, 2018 12:47 AM UTC

Hi Raghav,

Thank you for your interest in Syncfusion products.

In order to achieve the desired behavior, could you please make use of PdfGrid instead of PdfLightTable. Instead of making use of events, you can format the cell before drawing PdfGrid. Please check our documentation in the following link for more details.

Cell Content Formatting

Please try this and let me know if you have any questions.

Regards,
Geetha


n/a


SL Sowmiya Loganathan Syncfusion Team March 2, 2018 05:55 AM UTC

Hi Chleo, 

Apply different color and format for each cell depending upon the value can be achieved by using PdfGridCellStyle and PdfStringFormat class. Please refer the below UG documentation link for more details :  

Customize the cell in PdfGrid 

Customize the columns in PdfGrid 

Please try this in your end and let us know if you need any further assistance on this. 

Regards, 
Sowmiya L 


Loader.
Live Chat Icon For mobile
Up arrow icon