Click here to Skip to main content
12,953,937 members (42,859 online)
Rate this:
Please Sign up or sign in to vote.
See more:

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 ,
PdfPTable pdfTable = new PdfPTable(table.Columns.Count);
         iTextSharp.text.Rectangle rect = PageSize.LETTER;
               float pageWidth = rect.Width;
             if (pdfTable != null)
                         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 26-Sep-11 19:38pm
Updated 27-Sep-11 23:01pm

1 solution

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

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,464
CHill60 3,490
Maciej Los 3,123
ppolymorphe 2,020
Jochen Arndt 1,975

Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 1 Oct 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100