Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

I am doing code in C#.
I have created table using itextsharp, and binding my table with database,
so at every time i have no any idea about how many columns.
and i want my table in which column width is adjustable as par my data which is coming from database.

In below code ,if and only if, i know how much columns are their (in below case i.e 2 columns) so i used 2 width here ,
C#
PdfPTable pdfTable = new PdfPTable(table.Columns.Count);
         iTextSharp.text.Rectangle rect = PageSize.LETTER;
               float pageWidth = rect.Width;
             if (pdfTable != null)
             {
                 pdfTable.SetWidthPercentage(
                         new float[] {
                        (float).15 * pageWidth ,
                         (float).15 * pageWidth,
                                      }, rect);
             }




but when we have no any idea about number of columns(i.e when i binding pdfptable with my database) ,i can get count of columns , but how to set widths to each column widths as per data from database.
so plz help me..
Posted
Updated 27-Sep-11 23:01pm
v3

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900